Submission #497019

# Submission time Handle Problem Language Result Execution time Memory
497019 2021-12-22T08:31:03 Z kingline XOR Sum (info1cup17_xorsum) C++17
18 / 100
1600 ms 49456 KB
/*#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
//#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
#define pb push_back
//#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(data) data.begin() , data.end()
#define endl '\n'
//freopen("nenokku_easy.in", "r", stdin);
//freopen("nenokku_easy.out", "w", stdout);
//#define int long long
#define pii pair < int, int >
#define pll pair < long long, long long >

using namespace std;

typedef long long ll;
const int N = 1e6 + 5;
const int M = 350;
const int mod = 1e9 + 7;

int n, v[N];

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //file("pieaters");
    cin >> n;
    unordered_set < int > st;
    unordered_map < int, int > use;
    for(int i = 1; i <= n; i++) {
        cin >> v[i];
        st.insert(v[i]);
        use[v[i]]++;
    }
    int ans = 0;
    for(unordered_set < int >::iterator it = st.begin(); it != st.end();  it++) {
        int cnt = use[*it]; int cnt2 = (use[*it] + 1);
        if(cnt % 2) {
            if((cnt2 >> 1) % 2 == 1) ans ^= (*it) * 2;
        } else {
            if((cnt >> 1) % 2 == 1) ans ^= (*it) * 2;
        }
        unordered_set < int >::iterator itt = it;
        ++itt;
        while(itt != st.end()) {
            if(use[*it] % 2 == 1 && use[*itt] % 2 == 1) ans ^= (*itt) + (*it);
            ++itt;
        }
    }
    cout << ans;
}

/*
5 9 7
...##....
..#.##..#
..#....##
.##...#..
....#....
WS?EE??
*/









Compilation message

xorsum.cpp:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   29 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 202 ms 652 KB Output is correct
2 Correct 195 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 188 ms 4456 KB Output is correct
2 Correct 165 ms 4256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 188 ms 4456 KB Output is correct
2 Correct 165 ms 4256 KB Output is correct
3 Execution timed out 1690 ms 49456 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 202 ms 652 KB Output is correct
2 Correct 195 ms 588 KB Output is correct
3 Execution timed out 1688 ms 9604 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 202 ms 652 KB Output is correct
2 Correct 195 ms 588 KB Output is correct
3 Correct 188 ms 4456 KB Output is correct
4 Correct 165 ms 4256 KB Output is correct
5 Execution timed out 1690 ms 49456 KB Time limit exceeded
6 Halted 0 ms 0 KB -