답안 #517276

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
517276 2022-01-22T20:36:13 Z Ronin13 XOR Sum (info1cup17_xorsum) C++14
45 / 100
1600 ms 28860 KB
#include<bits/stdc++.h>
#define int long long
#define ull unsigned ll
#define pb push_back
#define epb emplace_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define inf 1e9+1
#define linf 1e18+1
using namespace std;
int dp[1001][101];
main(){
    int n;cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans=0;
    for(int bt=1;bt<=31;bt++){
        vector<int>vec;
        for(int i=1;i<=n;i++){
            vec.pb(a[i]%(1<<bt));
        }
        sort(vec.begin(),vec.end());
        int cnt=0;
        int l=(1<<(bt-1)),r=2*l;
        for(int to:vec){
            if(2*to>=l&&2*to<r)cnt++;
            if(2*to>=r+l)cnt++;
            cnt+=lower_bound(vec.begin(),vec.end(),r-to)-lower_bound(vec.begin(),vec.end(),l-to);
            cnt+=vec.end()-lower_bound(vec.begin(),vec.end(),r+l-to);
        }
        cnt>>=1;
        if(cnt&1)ans+=(1<<(bt-1));
    }
    cout<<ans;
    return 0;
}

Compilation message

xorsum.cpp:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 456 KB Output is correct
2 Correct 19 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1669 ms 28860 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1669 ms 28860 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 456 KB Output is correct
2 Correct 19 ms 316 KB Output is correct
3 Correct 504 ms 3864 KB Output is correct
4 Correct 478 ms 3880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 456 KB Output is correct
2 Correct 19 ms 316 KB Output is correct
3 Execution timed out 1669 ms 28860 KB Time limit exceeded
4 Halted 0 ms 0 KB -