Submission #522749

# Submission time Handle Problem Language Result Execution time Memory
522749 2022-02-05T16:01:47 Z Theo830 XOR Sum (info1cup17_xorsum) C++17
0 / 100
126 ms 131076 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9+7;
const ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ll,ii>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
int main(void){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin>>n;
    ll arr[n];
    f(i,0,n){
        cin>>arr[i];
    }
    const ll m = 30;
    ll pre[m][n];
    f(j,0,m){
        f(i,0,n){
            pre[j][i] = arr[i] % (1LL<<(j+1));
        }
        sort(pre[j],pre[j] + n);
    }
    ll ans = 0;
    ll posa[m] = {0};
    f(j,0,m){
        ///[2^j,2^(j+1) - 1]
        ///[2^(j+1) + 2^j,2^(j+2) - 1]
        ll L1 = (1LL<<j),R1 = (1LL<<(j+1)) - 1;
        ll L2 = (1LL<<j) + (1LL<<(j+1)),R2 = (1LL<<(j+2)) - 1;
        ll l1,r1,l2,r2;
        l1 = l2 = r1 = r2 = n - 1;
        f(i,0,n){
            l1 = max(i,l1);
            l2 = max(i,l2);
            while(l1 > 0 && pre[j][l1 - 1] + pre[j][i] >= L1){
                l1--;
            }
            while(l2 > 0 && pre[j][l2 - 1] + pre[j][i] >= L2){
                l2--;
            }
            while(r1 >= 0 && pre[j][r1] + pre[j][i] > R1){
                r1--;
            }
            while(r2 >= 0 && pre[j][r2] + pre[j][i] > R2){
                r2--;
            }
            if(r1 >= l1 && pre[j][i] + pre[j][l1] >= L1){
                posa[j] += r1 - l1 + 1;
            }
            if(r2 >= l2 && pre[j][i] + pre[j][l2] >= L2){
                posa[j] += r2 - l2 + 1;
            }
        }
    }
    f(j,0,m){
        ans += (1LL<<j) * (posa[j] % 2);
    }
    cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 120 ms 1228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 126 ms 131076 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 126 ms 131076 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 120 ms 1228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 120 ms 1228 KB Output isn't correct
2 Halted 0 ms 0 KB -