Submission #496761

# Submission time Handle Problem Language Result Execution time Memory
496761 2021-12-22T04:13:33 Z Nalrimet XOR Sum (info1cup17_xorsum) C++17
7 / 100
91 ms 131076 KB
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#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")

#include<bits/stdc++.h>
using namespace std;

const int N = 3 * 1e5 + 5;
const long long inf = 1000000000;
#define ll long long

#define F first
#define S second
#define pb push_back

int n, x[N];
bool used[5 * int(1e8) + 5];
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:25:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   25 |  main() {
      |  ^~~~
xorsum.cpp: In function 'int main()':
xorsum.cpp:51:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for(int i = 0; i < v.size(); ++i){
      |                    ~~^~~~~~~~~~
xorsum.cpp:52:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         for(int j = i; j < v.size(); ++j){
      |                        ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 14 ms 17204 KB Output is correct
2 Correct 14 ms 17100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 1592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 1592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 17204 KB Output is correct
2 Correct 14 ms 17100 KB Output is correct
3 Runtime error 91 ms 131076 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 17204 KB Output is correct
2 Correct 14 ms 17100 KB Output is correct
3 Incorrect 51 ms 1592 KB Output isn't correct
4 Halted 0 ms 0 KB -