# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
766211 | 2023-06-25T11:32:28 Z | Ahmed57 | XOR Sum (info1cup17_xorsum) | C++17 | 1458 ms | 21580 KB |
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; signed main(){ ios_base::sync_with_stdio(false);cin.tie(0); int n; cin>>n; int arr[n]; for(int i = 0;i<n;i++){ cin>>arr[i]; } sort(arr,arr+n); long long all = 0; reverse(arr,arr+n); for(int i = 0;i<=6;i++){ long long frq[(1<<(i+1))] = {0}; long long cnt = 0; for(int j = 0;j<n;j++){ frq[arr[j]&((1<<(i+1))-1)]++; } for(int j = 0;j<(1<<(i+1));j++){ for(int e = j;e<(1<<(i+1));e++){ if((j+e)&(1<<i)){ if(j==e)cnt+=(frq[j]*frq[e]+frq[j])/2; else cnt+=frq[j]*frq[e]; } } } if(cnt&1)all+=(1<<i); } for(int i = 7;i<30;i++){ vector<int> v; long long ans = 0; for(int j = 0;j<n;j++){ if((arr[j]+arr[j])&(1LL<<i)){ ans++; } v.push_back(arr[j]&((1LL<<(i+1))-1)); } sort(v.begin(),v.end()); int il = 0 , ir = 0; int ll = 0; for(int j = v.size()-1;j>=0;j--){ long long l=(1LL<<i),r=(1LL<<(i+1)); l-=v[j] , r-=v[j]; if(l<0){ l%=((1LL<<(i+1))); l+=(1LL<<(i+1)); l&=((1LL<<(i+1))-1); } while(ir<v.size()&&v[ir]<r)ir++; if(l>=ll){ while(il<v.size()&&v[il]<l)il++; }else{ il = 0; while(il<v.size()&&v[il]<l)il++; } //cout<<l<<" "<<r<<" "<<il<<" "<<ir<<" "<<v[il]<<" "<<v[ir]<<endl; ll = l; if(l<=r)ans+=(ir-il); else ans+=ir+(n-il); } //cout<<endl; if(((ans/2)&1))all+=(1LL<<i); } cout<<all<<endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 364 KB | Output is correct |
2 | Correct | 6 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 535 ms | 12304 KB | Output is correct |
2 | Correct | 498 ms | 11888 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 535 ms | 12304 KB | Output is correct |
2 | Correct | 498 ms | 11888 KB | Output is correct |
3 | Correct | 832 ms | 12240 KB | Output is correct |
4 | Correct | 806 ms | 12064 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 364 KB | Output is correct |
2 | Correct | 6 ms | 340 KB | Output is correct |
3 | Correct | 145 ms | 1620 KB | Output is correct |
4 | Correct | 146 ms | 1620 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 364 KB | Output is correct |
2 | Correct | 6 ms | 340 KB | Output is correct |
3 | Correct | 535 ms | 12304 KB | Output is correct |
4 | Correct | 498 ms | 11888 KB | Output is correct |
5 | Correct | 832 ms | 12240 KB | Output is correct |
6 | Correct | 806 ms | 12064 KB | Output is correct |
7 | Correct | 145 ms | 1620 KB | Output is correct |
8 | Correct | 146 ms | 1620 KB | Output is correct |
9 | Correct | 1458 ms | 12240 KB | Output is correct |
10 | Correct | 1443 ms | 21560 KB | Output is correct |
11 | Correct | 1441 ms | 21580 KB | Output is correct |