Submission #1114393

# Submission time Handle Problem Language Result Execution time Memory
1114393 2024-11-18T18:47:53 Z ttamx XOR Sum (info1cup17_xorsum) C++17
100 / 100
433 ms 26668 KB
#include<bits/stdc++.h>

using namespace std;

const int B=1<<30;

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto &x:a){
        cin >> x;
    }
    int ans=0;
    for(int b=1;b<B;b<<=1){
        vector<int> l,r;
        for(auto x:a){
            ((x&b)?r:l).emplace_back(x);
        }
        int c=0;
        for(int t=0;t<2;t++){
            for(int i=l.size()-1,p=0;i>=0;i--){
                while(p<l.size()&&!((l[i]+l[p])&b)){
                    p++;
                }
                if(p<=i){
                    c^=(i-p+1)&1;
                }
            }
            swap(l,r);
        }
        for(int i=r.size()-1,p=0;i>=0;i--){
            while(p<l.size()&&((r[i]+l[p])&b)){
                p++;
            }
            c^=p&1;
        }
        ans|=c*b;
        l.insert(l.end(),r.begin(),r.end());
        a=move(l);
    }
    cout << ans;
}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:24:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |                 while(p<l.size()&&!((l[i]+l[p])&b)){
      |                       ~^~~~~~~~~
xorsum.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             while(p<l.size()&&((r[i]+l[p])&b)){
      |                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 336 KB Output is correct
2 Correct 3 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 220 ms 23900 KB Output is correct
2 Correct 218 ms 16908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 220 ms 23900 KB Output is correct
2 Correct 218 ms 16908 KB Output is correct
3 Correct 281 ms 18988 KB Output is correct
4 Correct 261 ms 23912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 336 KB Output is correct
2 Correct 3 ms 336 KB Output is correct
3 Correct 57 ms 2408 KB Output is correct
4 Correct 51 ms 2568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 336 KB Output is correct
2 Correct 3 ms 336 KB Output is correct
3 Correct 220 ms 23900 KB Output is correct
4 Correct 218 ms 16908 KB Output is correct
5 Correct 281 ms 18988 KB Output is correct
6 Correct 261 ms 23912 KB Output is correct
7 Correct 57 ms 2408 KB Output is correct
8 Correct 51 ms 2568 KB Output is correct
9 Correct 433 ms 17908 KB Output is correct
10 Correct 423 ms 18044 KB Output is correct
11 Correct 411 ms 26668 KB Output is correct