Submission #270426

# Submission time Handle Problem Language Result Execution time Memory
270426 2020-08-17T15:22:32 Z Atill83 XOR Sum (info1cup17_xorsum) C++14
0 / 100
27 ms 5112 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n;
ll v[MAXN];
pii b[MAXN];
pii nw[MAXN];
int pw[45];
const int L = 29;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);


    cin>>n;

    for(int i = 0; i < n; i++){
        cin>>v[i];
        b[i] = {v[i] % 2, i};
    }
    
    sort(b, b + n);

    for(int i = 0; i <= L; i++){
        pw[i] = (1<<i);
    }

    ll ans = 0;

    for(int i = 0; i < 5; i++){
        ll cnt = 0;
        ll r3 = n, r2 = n, r1 = n;

        for(int j = 0; j < n; j++){
            while(r3 && b[j].ff + b[r3 - 1].ff >= pw[i] + pw[i + 1]) r3--;
            while(r2 && b[j].ff + b[r2 - 1].ff >= pw[i + 1]) r2--;
            while(r1 && b[j].ff + b[r1 - 1].ff >= pw[i]) r1--;
            cnt += n - r1 - (r3 - r2);
        }

        for(int j = 0; j < n; j++){
            if((2*b[j].ff) & pw[i]) cnt++;
        }
        assert(cnt % 2 == 0);
        cnt /= 2;
        if(cnt % 2) ans += pw[i];

        int last = 0;
        for(int j = 0; j < n; j++){
            if((v[b[j].ss] & pw[i + 1]) == 0){
                nw[last++] = b[j];
            }
        }

        for(int j = 0; j < n; j++){
            if((v[b[j].ss] & pw[i + 1])){
                b[j].ff += pw[i + 1];
                nw[last++] = b[j];
            }
        }
        for(int i = 0; i < n; i++){
            b[i] = nw[i];
            nw[i] = {-1, -1};
        }
    }

    cout<<ans<<endl;


    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 5112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 5112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -