Submission #649488

#TimeUsernameProblemLanguageResultExecution timeMemory
649488berrXOR Sum (info1cup17_xorsum)C++17
0 / 100
815 ms564 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); int n; cin>>n; if(n<5e3) { int ans=0; vector<int> a(n); for(int i=0; i<n; i++) cin>>a[i]; for(int i=0; i<n; i++) { for(int l=i; l<n; l++) { ans^=a[i]+a[l]; } } cout<<ans; } else { int ans=0; map<int, int> a; for(int i=0; i<n; i++){ int x; cin>>x; a[x]++;} for(int i=0; i<5e3; i++) { for(int l=i; l<5e3; l++) { if(a.count(l)&&a.count(i)) { if(l==i) { if((a[l]*a[l])%2) ans^=(l+i); } } else { if((a[l]*a[i])%2) ans^=(l+i); } } } cout<<ans; } }

Compilation message (stderr)

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