Submission #1318260

#TimeUsernameProblemLanguageResultExecution timeMemory
1318260g31niusXOR Sum (info1cup17_xorsum)C++20
45 / 100
1694 ms15996 KiB
#include <iostream> #include <algorithm> #include <cmath> using namespace std; long long i, j, n, v[1000001], aux1, aux2, k, w[1000001], st, dr, st2, dr2; long long sum, mod, mod2, mod3, auxi, cnt, cnt2; int main() { cin >> n; for ( i = 1; i <= n; i++ ) { cin >> v[i]; } for ( k = 30; k >= 0; k-- ) { auxi = 0; mod = pow ( 2, k+1 ); mod2 = pow ( 2, k ); for ( i = 1; i <= n; i++ ) { w[i] = v[i]%mod; } sort ( w+1, w+n+1 ); for ( i = 1; i <= n; i++ ) { st = lower_bound ( w+i, w+n+1, mod2-w[i] )-w; if ( w[st] >= mod2-w[i] && st <= n && st >= i ) { dr = lower_bound( w+i, w+n+1, mod-w[i] )-w; dr--; if ( dr >= st && w[dr] < mod-w[i] && dr <= n && dr >= i ) { auxi += (dr-st+1); } } st = lower_bound ( w+i, w+n+1, mod+mod2-w[i] )-w; if ( w[st] >= mod+mod2-w[i] && st <= n && st >= i ) { dr = lower_bound ( w+i, w+n+1, mod*2-w[i] )-w; dr--; if ( dr >= st && w[dr] < mod*2-w[i] && dr <= n && dr >= i ) { auxi += (dr-st+1); } } /*if ( w[i]+w[j] >= mod2 && w[i]+w[j] < mod ) { auxi++; } else if ( w[i]+w[j] >= mod+mod2 && w[i]+w[j] < mod*2 ) { auxi++; }*/ } if ( auxi%2 == 1 ) { sum += mod2; } } cout << sum; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...