답안 #646404

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
646404 2022-09-29T18:19:07 Z murad_2005 XOR Sum (info1cup17_xorsum) C++17
45 / 100
1288 ms 4404 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));
                }
            }
        }
    }
    cout << 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;
}

Compilation message

xorsum.cpp: In function 'int Subtask2(int)':
xorsum.cpp:71:1: warning: no return statement in function returning non-void [-Wreturn-type]
   71 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 212 KB Output is correct
2 Correct 6 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 405 ms 4404 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 405 ms 4404 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 212 KB Output is correct
2 Correct 6 ms 212 KB Output is correct
3 Correct 1288 ms 660 KB Output is correct
4 Correct 1283 ms 664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 212 KB Output is correct
2 Correct 6 ms 212 KB Output is correct
3 Runtime error 405 ms 4404 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -