# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
900540 |
2024-01-08T13:14:53 Z |
pcc |
XOR Sum (info1cup17_xorsum) |
C++17 |
|
458 ms |
16796 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int H = 10;
const int mxn = 1e6+10;
int arr[mxn],brr[mxn];
int ans;
int cnt[mxn];
int n;
int sum;
inline void add(int p){
sum += cnt[p];
return;
}
inline void del(int p){
sum -= cnt[p];
return;
}
inline int calc(int bit){
int h = 1<<(bit+1);
h--;
memset(cnt,0,sizeof(cnt));
sum = 0;
for(int i = 1;i<=n;i++){
brr[i] = arr[i];
brr[i] &= h;
}
sort(brr+1,brr+n+1);
int re = 0;
int pl = 0,pr = 0;
//cout<<bit<<":";for(int i = 1;i<=n;i++)cout<<brr[i]<<' ';cout<<endl;
for(int i = n;i>=1;i--){
cnt[i]++;
if(pl<=i&&pr>i)sum++;
int lp = (1<<bit)-brr[i],rp = (1ll<<(bit+1))-brr[i];
while(pr<=n&&brr[pr]<rp)add(pr++);
while(pl<=n&&brr[pl]<lp)del(pl++);
//cout<<i<<','<<pl<<','<<pr<<','<<sum<<endl;
re += sum;
}
memset(cnt,0,sizeof(cnt));
sum = 0;
pl = pr = 0;
for(int i = n;i>=1;i--){
cnt[i]++;
if(pl<=i&&pr>i)sum++;
ll lp = (1ll<<bit)*3-brr[i],rp = (1ll<<(bit+2))-brr[i];
while(pr<=n&&brr[pr]<rp)add(pr++);
while(pl<=n&&brr[pl]<lp)del(pl++);
re += sum;
}
return re&1;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
for(int i = 1;i<=n;i++)cin>>arr[i];
for(int i =0;i<=H;i++)ans ^= calc(i)<<i;
//for(int i = 0;i<=H;i++)cout<<i<<":"<<calc(i)<<endl;
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
6744 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
458 ms |
16796 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
458 ms |
16796 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
6744 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
6744 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |