답안 #496732

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
496732 2021-12-22T03:36:16 Z kingline XOR Sum (info1cup17_xorsum) C++17
7 / 100
74 ms 8192 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>
#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[N];

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //file("pieaters");
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> v[i];
    }
    if(n <= 4000) {
        int ans = 0;
        for(int i = 1; i <= n; i++) {
            for(int j = i; j <= n; j++) {
                ans ^= (v[i] + v[j]);
            }
        }
        cout << ans;
    } else {
        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;
    }
}

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









Compilation message

xorsum.cpp:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   27 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 6 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 74 ms 8192 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 74 ms 8192 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 6 ms 332 KB Output is correct
3 Runtime error 15 ms 2008 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 6 ms 332 KB Output is correct
3 Incorrect 74 ms 8192 KB Output isn't correct
4 Halted 0 ms 0 KB -