Submission #646228

# Submission time Handle Problem Language Result Execution time Memory
646228 2022-09-29T09:12:54 Z murad_2005 XOR Sum (info1cup17_xorsum) C++14
0 / 100
1600 ms 10496 KB
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define ui unsigned int
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define pf push_front
#define pii pair<int, int>
#define pil pair<int, ll>
#define plli pair<long long, int>
#define pdi pair<double, int>
#define pldldi pair<ld, pair<ld, int>>
#define pdd pair<double, double>
#define pid pair<int, double>
#define piii pair<int, pair<int, int>>
#define pllll pair<long long, long long>
#define pllllll pair<ll, pllll>
#define INF 2e9 + 5
#define size(v) v.size()
#define f first
#define s second
#define Pi 3.14159265359

using namespace std;

const int up = 4e3 + 5;

void solve(){
    int n;
    cin >> n;
    vector<int>a(n);
    vector<vector<int>>g(up);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        g[a[i]].pb(i);
    }
    ll Res = 0;
    for(int i = 1; i < up; ++i){
        for(int j = 1; j < up; j++){
            if(i != j && size(g[i]) > 0 && size(g[j]) > 0){
                int Sum = 0;
                for(int pos : g[i]){
                    int p = upper_bound(all(g[j]), pos) - g[j].begin();
                    int cnt = size(g[j]) - p;
                    if(!cnt) break;
                    Sum += cnt;
                }
                if(Sum & 1){
                    Res ^= (1ll * i + j);
                }
            }if(i == j && size(g[i]) > 0){
                if(size(g[i]) & 1){
                    Res ^= (2ll * i);
                }
                int N = size(g[j]);
                if((N * (N - 1) / 2) & 1){
                    Res ^= (2ll * i);
                }
            }
        }
    }
    cout << Res;

}

int main(){

    int t;
    t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1634 ms 10496 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1634 ms 10496 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -