답안 #496852

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
496852 2021-12-22T05:27:54 Z kingline XOR Sum (info1cup17_xorsum) C++17
56 / 100
1600 ms 7068 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], used[5005];

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //file("pieaters");
    cin >> n;
    int mx = 0;
    for(int i = 1; i <= n; i++) {
        cin >> v[i];
        mx = max(mx, v[i]);
    }
    if(mx <= 5000){
        for(int i = 1; i <= n; i++) {
            used[v[i]]++;
        }
        int ans = 0;
        for(int i = 1; i <= 4000; i++) {
            if(used[i] == 0) continue;
            int cnt = used[i] * (used[i] + 1) / 2;
            if(cnt % 2) ans ^= (i * 2);
            //cout << cnt << " " << i << endl;
            for(int j = i + 1; j <= 4000; j++) {
                if(used[j] == 0) continue;
                cnt = used[i] * used[j];
                if(cnt % 2) ans ^= (i + j);
            }
        }
        cout << ans;
    } else {
        int ans = 0;
        for(int i = 1; i <= n; i++) {
            for(int j = i; j <= n; j++) {
                ans ^= (v[i] + v[j]);
            }
        }
        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() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 7068 KB Output is correct
2 Correct 70 ms 5716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 7068 KB Output is correct
2 Correct 70 ms 5716 KB Output is correct
3 Execution timed out 1668 ms 5952 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 485 ms 636 KB Output is correct
4 Correct 486 ms 1632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 76 ms 7068 KB Output is correct
4 Correct 70 ms 5716 KB Output is correct
5 Execution timed out 1668 ms 5952 KB Time limit exceeded
6 Halted 0 ms 0 KB -