Submission #886955

#TimeUsernameProblemLanguageResultExecution timeMemory
886955Zero_OPXOR Sum (info1cup17_xorsum)C++14
77 / 100
1606 ms14080 KiB
#include<bits/stdc++.h> using namespace std; #define range(v) begin(v), end(v) #define compact(v) v.erase(unique(range(v)), end(v)) template<class T> bool minimize(T& a, T b){ if(a > b) return a = b, true; return false; } template<class T> bool maximize(T& a, T b){ if(a < b) return a = b, true; return false; } typedef long long ll; typedef unsigned long long ull; typedef long double ld; void Zero_OP(){ int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; ++i){ cin >> a[i]; } int ans = 0; for(int target = 30; target >= 0; --target){ //last target bits for(int i = 0; i < n; ++i){ a[i] %= (1 << (target + 1)); } sort(range(a)); ll cur = 0; int j = n, k = n, l = n; for(int i = 0; i < n; ++i){ maximize(j, i); maximize(k, i); maximize(l, i); while(i < j and a[i] + a[j - 1] >= (1 << target)) --j; while(i < k and a[i] + a[k - 1] > ((1 << (target + 1)) - 1)) --k; while(i < l and a[i] + a[l - 1] >= (1 << (target + 1)) + (1 << target)) --l; cur += k - j; cur += n - l; } if(cur & 1) ans ^= (1 << target); } cout << ans << '\n'; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #define task "antuvu" if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } Zero_OP(); return 0; }

Compilation message (stderr)

xorsum.cpp: In function 'int main()':
xorsum.cpp:62:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |     freopen(task".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
xorsum.cpp:63:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |     freopen(task".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...