Submission #799601

# Submission time Handle Problem Language Result Execution time Memory
799601 2023-07-31T16:25:01 Z Darren0724 XOR Sum (info1cup17_xorsum) C++17
56 / 100
1600 ms 8276 KB
#pragma GCC optimize("Ofast","O3","unroll-loops")
#pragma GCC target("avx2")
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define rz resize
#define pb emplace_back
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define ACorz ios_base::sync_with_stdio(false);cin.tie(0);
//#define endl '\n'
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int INF=1e9,INF2=2e9;
const int mod=1e9+7;
const int mod1=998244353;
const int N=100;
const int K=45000;
const int M=5000;

signed main(){
    ACorz;
    int n;cin>>n;
    vector<int> v(n);
    
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        if(n%2==0){
            ans^=v[i];
        }
    }
    int p=2;
    for(int i=1;i<=29;i++){
        vector<int> a(n);
        for(int j=0;j<n;j++){
            a[j]=v[j]%p;
        }
        sort(all(a));
        int cnt=0;
        int t=n-1;
        for(int j=0;j<n;j++){
            while(t>=0&&a[t]+a[j]>=p){
                t--;
            }
            cnt+=(n-1-t);
        }
        for(int j=0;j<n;j++){
            if(a[j]+a[j]>=p){
                cnt++;
            }
        }
        cnt/=2;
        //cout<<cnt<<endl;
        if(cnt&1){
            ans^=p;
        }
        p<<=1;
    }
    cout<<ans<<endl;

    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 340 KB Output is correct
2 Correct 7 ms 392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1434 ms 8148 KB Output is correct
2 Correct 1366 ms 7744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1434 ms 8148 KB Output is correct
2 Correct 1366 ms 7744 KB Output is correct
3 Execution timed out 1650 ms 8276 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 340 KB Output is correct
2 Correct 7 ms 392 KB Output is correct
3 Correct 183 ms 1236 KB Output is correct
4 Correct 181 ms 1240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 340 KB Output is correct
2 Correct 7 ms 392 KB Output is correct
3 Correct 1434 ms 8148 KB Output is correct
4 Correct 1366 ms 7744 KB Output is correct
5 Execution timed out 1650 ms 8276 KB Time limit exceeded
6 Halted 0 ms 0 KB -