답안 #517280

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
517280 2022-01-22T20:46:23 Z Ronin13 XOR Sum (info1cup17_xorsum) C++14
56 / 100
1600 ms 8128 KB
#include<bits/stdc++.h>
#define ll 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;
    ios_base::sync_with_stdio(false);cin.tie(0);
    int a[n+1];
    int mx=0;

    for(int i=1;i<=n;i++){
        cin>>a[i];
        mx=max(mx,a[i]);
    }
    mx=log2(mx);
    int ans=0;
    int vec[n];
    for(int bt=1;bt<=mx+2;bt++){

        for(int i=0;i<n;i++){
            vec[i]=a[i+1]%(1<<bt);

        }
        sort(vec,vec+n);
        int cnt=0;
        int l=(1<<(bt-1)),r=2*l;
        for(int i=0;i<n;i++){
            int to=vec[i];
            if(2*to>=l&&2*to<r)cnt++;
            if(2*to>=r+l)cnt++;
            cnt+=lower_bound(vec,vec+n,r-to)-lower_bound(vec,vec+n,l-to);
            cnt+=vec+n-lower_bound(vec,vec+n,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 332 KB Output is correct
2 Correct 16 ms 352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1569 ms 8128 KB Output is correct
2 Correct 1462 ms 7592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1569 ms 8128 KB Output is correct
2 Correct 1462 ms 7592 KB Output is correct
3 Execution timed out 1663 ms 8052 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 332 KB Output is correct
2 Correct 16 ms 352 KB Output is correct
3 Correct 482 ms 1080 KB Output is correct
4 Correct 464 ms 1100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 332 KB Output is correct
2 Correct 16 ms 352 KB Output is correct
3 Correct 1569 ms 8128 KB Output is correct
4 Correct 1462 ms 7592 KB Output is correct
5 Execution timed out 1663 ms 8052 KB Time limit exceeded
6 Halted 0 ms 0 KB -