Submission #736495

# Submission time Handle Problem Language Result Execution time Memory
736495 2023-05-05T18:59:43 Z sq00 XOR Sum (info1cup17_xorsum) C++14
7 / 100
1600 ms 4372 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    cin.tie(0)->sync_with_stdio(0);
//    freopen("div7.in", "r", stdin);
//    freopen("div7.out", "w", stdout);
    int n;
    cin >> n;
    if(n <= 4e3){
        vector<int>v(n);
        for(int i = 0; i < n; i++) {cin >> v[i];}
        int ans = 0;
        for(int i = 0; i < n; i++) {
            for(int e = i; e < n; e++) {
                ans ^= v[i] + v[e];
            }
        }
        cout << ans;
        return 0;
    }
    map<int, int>mp;
    vector<int>v(n);
    for(int i = 0;i < n;++i){
        cin >> v[i];
    }
    int ans = 0;
    for(int i = 0;i < n;++i){
        if(mp.count(v[i])){
            ans ^= mp[v[i]];
        }
        int res = 0;
        for(int j = i;j < n;++j){
            res ^= (v[i] + v[j]);
            ans ^= (v[i] + v[j]);
        }
        mp[v[i]] = res;
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 212 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1660 ms 4372 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1660 ms 4372 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 212 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
3 Execution timed out 1658 ms 2232 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 212 KB Output is correct
2 Correct 4 ms 340 KB Output is correct
3 Execution timed out 1660 ms 4372 KB Time limit exceeded
4 Halted 0 ms 0 KB -