답안 #646405

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
646405 2022-09-29T18:20:21 Z murad_2005 XOR Sum (info1cup17_xorsum) C++14
56 / 100
1600 ms 36424 KB
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2")
#pragma GCC optimize("unroll-loops")
#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;

int Subtask1and5(int n){
    int a[n + 1];
    ll Res = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        for(int j = 1; j <= i; j++){
            Res ^= (a[i] + a[j]);
        }
    }
    return Res;
}

int Subtask2(int n){
    vector<int>a(n);
    map<int, int>mp;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        mp[a[i]]++;
    }
    ll Res = 0;
    for(auto i = mp.begin(); i != mp.end(); i++){
        for(auto j = i; j != mp.end(); j++){
            if(i == j){
                int c = i->f;
                int x = i->s;
                if(x & 1){
                    Res ^= (2ll * c);
                }if((x * (x - 1) / 2) & 1){
                    Res ^= (2ll * c);
                }
            }else{
                int x = i->s, y = j->s;
                if((1ll * x * y) & 1){
                    Res ^= (1ll * (i->f) + (j->f));
                }
            }
        }
    }
    return Res;
}


void solve(){
    int n;
    cin >> n;
    if(n <= 100000){
        cout << Subtask1and5(n);
    }else{
        cout << Subtask2(n);
    }
}

int main(){

    int t;
    t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 212 KB Output is correct
2 Correct 4 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 386 ms 4408 KB Output is correct
2 Correct 359 ms 8344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 386 ms 4408 KB Output is correct
2 Correct 359 ms 8344 KB Output is correct
3 Execution timed out 1692 ms 36424 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 212 KB Output is correct
2 Correct 4 ms 212 KB Output is correct
3 Correct 1315 ms 668 KB Output is correct
4 Correct 1296 ms 660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 212 KB Output is correct
2 Correct 4 ms 212 KB Output is correct
3 Correct 386 ms 4408 KB Output is correct
4 Correct 359 ms 8344 KB Output is correct
5 Execution timed out 1692 ms 36424 KB Time limit exceeded
6 Halted 0 ms 0 KB -