답안 #496779

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
496779 2021-12-22T04:28:46 Z Nalrimet XOR Sum (info1cup17_xorsum) C++17
56 / 100
1600 ms 56488 KB
#include<bits/stdc++.h>
 
#pragma GCC optimization("g", on)
#pragma GCC optimize ("inline")
#pragma GCC optimization("03")
#pragma GCC optimization("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popused,abm,mmx,avx,tune=native")
using namespace std;
 
const int N = 1e6 + 5;
const long long inf = 1000000000;
#define ll long long
 
#define F first
#define S second
#define pb push_back
 
int n, x[N];
map<int, bool> used;
map<int, int> cnt;
vector<int> v;
long long res, f;
 
 main() {
 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    cin >> n;
 
    for(int i = 1; i <= n; ++i){
        cin >> x[i];
        used[x[i]] = !used[x[i]];
        cnt[x[i]]++;
    }
 
    for(int i = 1; i <= n; ++i){
        if(cnt[x[i]]) {
            f = cnt[x[i]];
            if(f * (f - 1) / 2 % 2 == 1) res ^= x[i] + x[i];
            cnt[x[i]] = 0;
        }
        if(used[x[i]]) {
            v.pb(x[i]);
            used[x[i]] = 0;
        }
    }
 
    for(int i = 0; i < v.size(); ++i){
        for(int j = i; j < v.size(); ++j){
            res ^= v[i] + v[j];
        }
    }
 
    cout << res;
 
}

Compilation message

xorsum.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization("g", on)
      | 
xorsum.cpp:5: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    5 | #pragma GCC optimization("03")
      | 
xorsum.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    6 | #pragma GCC optimization("unroll-loops")
      | 
xorsum.cpp:7: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    7 | #pragma comment(linker, "/stack:200000000")
      | 
xorsum.cpp:26:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   26 |  main() {
      |  ^~~~
xorsum.cpp: In function 'int main()':
xorsum.cpp:52:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(int i = 0; i < v.size(); ++i){
      |                    ~~^~~~~~~~~~
xorsum.cpp:53:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         for(int j = i; j < v.size(); ++j){
      |                        ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 716 KB Output is correct
2 Correct 5 ms 672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 428 ms 4600 KB Output is correct
2 Correct 390 ms 4340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 428 ms 4600 KB Output is correct
2 Correct 390 ms 4340 KB Output is correct
3 Execution timed out 1685 ms 56488 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 716 KB Output is correct
2 Correct 5 ms 672 KB Output is correct
3 Correct 1133 ms 10628 KB Output is correct
4 Correct 1167 ms 10648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 716 KB Output is correct
2 Correct 5 ms 672 KB Output is correct
3 Correct 428 ms 4600 KB Output is correct
4 Correct 390 ms 4340 KB Output is correct
5 Execution timed out 1685 ms 56488 KB Time limit exceeded
6 Halted 0 ms 0 KB -