Submission #4037503


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* main */

signed main(){
    ll N;
    cin >> N;
    vector<ll> a(N);
    vector<ll> a2(N);
    vector<ll> a3(N);
    FOR(i,0,N)cin >> a[i];
    FOR(i,0,N)a2[i] = a[i]-1;
    FOR(i,0,N)a3[i] = a[i]^a2[i];
    sort(ALL(a3));
    reverse(ALL(a3));
    ll XOR = 0;
    ll ans = 0;
    FOR(i,0,N)XOR ^= a[i];
    for(auto x:a3){
        if(XOR^x < XOR){
            ans++;
            XOR ^= x;
        }
    }
    if(XOR == 0)cout << ans << endl;
    else cout << -1 << endl;
}

Submission Info

Submission Time
Task C - Cheating Nim
User nu50218
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2327 Byte
Status WA
Exec Time 16 ms
Memory 2560 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 2
AC × 13
WA × 13
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 1 ms 256 KB
001.txt AC 1 ms 256 KB
002.txt AC 14 ms 2560 KB
003.txt WA 7 ms 1664 KB
004.txt AC 7 ms 1408 KB
005.txt AC 5 ms 896 KB
006.txt WA 15 ms 2560 KB
007.txt WA 15 ms 2560 KB
008.txt WA 15 ms 2560 KB
009.txt WA 15 ms 2560 KB
010.txt WA 15 ms 2560 KB
011.txt WA 15 ms 2560 KB
012.txt WA 15 ms 2560 KB
013.txt WA 15 ms 2560 KB
014.txt WA 15 ms 2560 KB
015.txt WA 15 ms 2560 KB
016.txt AC 15 ms 2560 KB
017.txt AC 16 ms 2560 KB
018.txt WA 15 ms 2560 KB
019.txt WA 15 ms 2560 KB
020.txt AC 15 ms 2560 KB
021.txt AC 2 ms 512 KB
022.txt AC 2 ms 512 KB
023.txt AC 13 ms 2560 KB
example0.txt AC 1 ms 256 KB
example1.txt AC 1 ms 256 KB