diff --git a/**TEMPATE.cpp b/**TEMPATE.cpp deleted file mode 100644 index b22ae91..0000000 --- a/**TEMPATE.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include -#include -#include - -using namespace std ; - -long long int main() { - - long long int t ; - cin >> t ; - - while ( t-- ) { - - long long int n, k, m ; - cin >> n ; - vector< long long int > v(n) ; - - for ( auto i = 0 ; i < n ; ++i ) - cin >> v[i] ; - - - - - } - -} \ No newline at end of file diff --git a/AUG19B/1.cpp b/AUG19B/1.cpp old mode 100755 new mode 100644 index 480d845..7b8a411 --- a/AUG19B/1.cpp +++ b/AUG19B/1.cpp @@ -1,35 +1,35 @@ -#include -#include - -using namespace std; - -int main() { - - short int t ; - cin >> t ; - - while ( t-- ) { - - int n ; - cin >> n ; - vector< int > a(n), b(n) ; - - for ( auto i = 0 ; i < n ; ++i ) - cin >> a[i] ; - for ( auto i = 0 ; i < n ; ++i ) - cin >> b[i] ; - - int ans = 0 ; - //cout << '\n' ; - for ( auto i = 0 ; i < n ; ++i ) { - int res = a[i]*20 - b[i]*10 ; - //cout << res << '\n' ; - ans = max(res,ans) ; - } - - cout << ans << '\n' ; - - } - - return 0; -} +#include +#include + +using namespace std; + +int main() { + + short int t ; + cin >> t ; + + while ( t-- ) { + + int n ; + cin >> n ; + vector< int > a(n), b(n) ; + + for ( auto i = 0 ; i < n ; ++i ) + cin >> a[i] ; + for ( auto i = 0 ; i < n ; ++i ) + cin >> b[i] ; + + int ans = 0 ; + //cout << '\n' ; + for ( auto i = 0 ; i < n ; ++i ) { + int res = a[i]*20 - b[i]*10 ; + //cout << res << '\n' ; + ans = max(res,ans) ; + } + + cout << ans << '\n' ; + + } + + return 0; +} diff --git a/AUG19B/2.cpp b/AUG19B/2.cpp old mode 100755 new mode 100644 index 63f9e92..e25bfb1 --- a/AUG19B/2.cpp +++ b/AUG19B/2.cpp @@ -1,22 +1,22 @@ -#include -using namespace std; - -int main() { - - short int t ; - cin >> t ; - - while ( t-- ) { - - long long unsigned int n, k ; - cin >> n >> k ; - - if ( k==1 || k*k == n ) - cout << "NO\n" ; - else - cout << "YES\n" ; - - } - - return 0; -} +#include +using namespace std; + +int main() { + + short int t ; + cin >> t ; + + while ( t-- ) { + + long long unsigned int n, k ; + cin >> n >> k ; + + if ( k==1 || k*k == n ) + cout << "NO\n" ; + else + cout << "YES\n" ; + + } + + return 0; +} diff --git a/AUG19B/a.exe b/AUG19B/a.exe old mode 100755 new mode 100644 diff --git a/AUG19B/ks1 b/AUG19B/ks1 old mode 100755 new mode 100644 diff --git a/AUG19B/ks1.cpp b/AUG19B/ks1.cpp old mode 100755 new mode 100644 index 36d34e4..7f1fe31 --- a/AUG19B/ks1.cpp +++ b/AUG19B/ks1.cpp @@ -1,102 +1,102 @@ -#include -#include -#include -#include -#include -#include - -using namespace std ; - -int main() { - - int t ; - cin >> t ; - - while ( t-- ) { - - int n; - bool f= 0 ; - cin >> n ; - - vector< int > v(n), xor1(n+1), sum(n,0) ; - - - for ( auto i = 0 ; i < n ; ++i ) { - cin >> v[i] ; - if ( f ) { - sum[i] = sum[i-1] + v[i] ; - } - else f=1 ; - } - - xor1[0] = 0 ; - for ( auto i = 0 ; i < n ; ++i ) { - xor1[i+1] = xor1[i]^v[i] ; - } - - int ans = 0 ; - - unordered_map< int, vector< int > > h ; - - for ( auto i = 0 ; i < n+1 ; ++i ) - h[xor1[i]].push_back( i ) ; - - - //for ( auto i : xor1 ) - //cout << i << ' ' ; - - for ( auto i : h ) { - f = 0 ; - int prev=0, next ; - for ( auto j : i.second ) { - if ( f!=0 ) { - next = j ; - ans += next-prev-1 ; - prev = next ; - //if ( i.first == 0 ) - //ans += next + prev ; - } - else { - prev = j ; - f = 1; - } - } - } - cout << ans << '\n' ; - - } - -} - - - /* - unordered_map< int, vector< int > > h ; - - for ( auto i = 0 ; i < n ; ++i ) - h[xor1[i]].push_back( i ) ; - - - for ( auto i : xor1 ) { - cout << i << ' ' ; - } - cout << "\n\n\n"; - - cout << '\n' << '\n' ; - for ( auto i : h ) { - f = 0 ; - int prev, next ; - for ( auto j : i.second ) { - if ( f==0 ) { - f=1 ; - continue ; - prev = j ; - } - next = j ; - ans += next-prev ; - if ( i.first == 0 ) { - ans += next + prev ; - } - prev = next ; - } - } +#include +#include +#include +#include +#include +#include + +using namespace std ; + +int main() { + + int t ; + cin >> t ; + + while ( t-- ) { + + int n; + bool f= 0 ; + cin >> n ; + + vector< int > v(n), xor1(n+1), sum(n,0) ; + + + for ( auto i = 0 ; i < n ; ++i ) { + cin >> v[i] ; + if ( f ) { + sum[i] = sum[i-1] + v[i] ; + } + else f=1 ; + } + + xor1[0] = 0 ; + for ( auto i = 0 ; i < n ; ++i ) { + xor1[i+1] = xor1[i]^v[i] ; + } + + int ans = 0 ; + + unordered_map< int, vector< int > > h ; + + for ( auto i = 0 ; i < n+1 ; ++i ) + h[xor1[i]].push_back( i ) ; + + + //for ( auto i : xor1 ) + //cout << i << ' ' ; + + for ( auto i : h ) { + f = 0 ; + int prev=0, next ; + for ( auto j : i.second ) { + if ( f!=0 ) { + next = j ; + ans += next-prev-1 ; + prev = next ; + //if ( i.first == 0 ) + //ans += next + prev ; + } + else { + prev = j ; + f = 1; + } + } + } + cout << ans << '\n' ; + + } + +} + + + /* + unordered_map< int, vector< int > > h ; + + for ( auto i = 0 ; i < n ; ++i ) + h[xor1[i]].push_back( i ) ; + + + for ( auto i : xor1 ) { + cout << i << ' ' ; + } + cout << "\n\n\n"; + + cout << '\n' << '\n' ; + for ( auto i : h ) { + f = 0 ; + int prev, next ; + for ( auto j : i.second ) { + if ( f==0 ) { + f=1 ; + continue ; + prev = j ; + } + next = j ; + ans += next-prev ; + if ( i.first == 0 ) { + ans += next + prev ; + } + prev = next ; + } + } */ \ No newline at end of file diff --git a/Algorithms/FLOYD_LL b/Algorithms/FLOYD_LL old mode 100755 new mode 100644 diff --git a/Algorithms/Rev_LL_Recurse b/Algorithms/Rev_LL_Recurse old mode 100755 new mode 100644 diff --git a/Algorithms/a b/Algorithms/a old mode 100755 new mode 100644 diff --git a/CF_495_D2_V/A b/CF_495_D2_V/A old mode 100755 new mode 100644 diff --git a/CF_656_D3/A.cpp b/CF_656_D3/A.cpp new file mode 100644 index 0000000..f67a651 --- /dev/null +++ b/CF_656_D3/A.cpp @@ -0,0 +1,52 @@ + #include + using namespace std; + int main() + { + long long int t,i,x,y,z,a,b,c; + cin>>t; + for(i=0;i>x>>y>>z; + if(x==y) + { + if(x>=z) + { + cout<<"YES\n"; + cout<=x) + { + cout<<"YES\n"; + cout<=y) + { + cout<<"YES\n"; + cout< -#include -#include -#include -#include - -using namespace std ; - -int main() { - - int t ; - cin >> t ; - - while ( t-- ) { - - int n ; - cin >> n ; - vector< int > v(n) ; - - for ( auto i = 0 ; i < n ; ++i ) - cin >> v[i] ; - - sort( v.begin(), v.end() ) ; - - if ( n%2 == 0 ) { - - string code = "" ; - - for ( auto i = 1 ; i < n-2 ; i+=2 ) { - - int res = ( v[i+2] - v[i] ) ; - ( res < 0 )? res *= -1 : 1 ; - - code += to_string(res) ; - - } - - code += to_string( v[n-1] - v[n-2] ) ; - - for ( auto i = n-2 ; i >= 2 ; i -= 2 ) { - - int res = ( v[i] - v[i-2] ) ; - ( res < 0 )? res *= -1 : 1 ; - - code += to_string(res) ; - - } - - string code2 = code ; - reverse( code.begin(), code.end() ) ; - - if ( code == code2 ) - cout << code << endl ; - else - cout << "Key combination cannot be cracked\n" ; - - - } - - else { - - string code = "" ; - - for ( auto i = 0 ; i < n-2 ; i+=2 ) { - - int res = ( v[i+2] - v[i] ) ; - ( res < 0 )? res *= -1 : 1 ; - - code += to_string(res) ; - - } - - code += to_string( v[n-1] - v[n-2] ) ; - - for ( auto i = n-2 ; i >= 2 ; i -= 2 ) { - - int res = ( v[i] - v[i-2] ) ; - ( res < 0 )? res *= -1 : 1 ; - - code += to_string(res) ; - - } - - code += to_string(v[1] - v[0]) ; - - string code2 = code ; - reverse( code.begin(), code.end() ) ; - - if ( code == code2 ) - cout << code << endl ; - else - cout << "Key combination cannot be cracked\n" ; - - - } - - } - -} \ No newline at end of file diff --git a/DynamicProgramming/Min_Steps_To_One b/DynamicProgramming/Min_Steps_To_One old mode 100755 new mode 100644 diff --git "a/DynamicProgramming\\Min_Steps_To_One" "b/DynamicProgramming\\Min_Steps_To_One" deleted file mode 100755 index c2ef5a2..0000000 Binary files "a/DynamicProgramming\\Min_Steps_To_One" and /dev/null differ diff --git a/Leetcode_30DaysChallenge/3_3_NumOfIslands b/Leetcode_30DaysChallenge/3_3_NumOfIslands old mode 100755 new mode 100644 diff --git a/NOV19B/run b/NOV19B/run old mode 100755 new mode 100644 diff --git a/SearchINRowWiseColWiseMatrix b/SearchINRowWiseColWiseMatrix old mode 100755 new mode 100644