Submission #18981820


Source Code Expand

Copy
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}

int n, a[100005], x, ans;
bool ok[32];

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	repn(i, n){
		cin >> a[i]; x ^= a[i];
		int p = __builtin_ctz(a[i]);
		ok[p] = 1;
	}
	for(int i=0;i<30;i++){
		int a = !!(x & (1<<i));
		int b = !!(x & (2<<i));
		if(a != b){
			if(!ok[i]){
				cout << -1 << endl;
				return 0;
			}
			ans++;
		}
	}
	cout << ans << endl;
}

Submission Info

Submission Time
Task C - Cheating Nim
User IH19980412
Language C++ (GCC 9.2.1)
Score 500
Code Size 1784 Byte
Status AC
Exec Time 23 ms
Memory 3956 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 26
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 12 ms 3420 KB
001.txt AC 2 ms 3452 KB
002.txt AC 16 ms 3808 KB
003.txt AC 9 ms 3756 KB
004.txt AC 14 ms 3620 KB
005.txt AC 7 ms 3544 KB
006.txt AC 17 ms 3808 KB
007.txt AC 18 ms 3736 KB
008.txt AC 15 ms 3908 KB
009.txt AC 15 ms 3812 KB
010.txt AC 22 ms 3732 KB
011.txt AC 19 ms 3780 KB
012.txt AC 23 ms 3836 KB
013.txt AC 21 ms 3776 KB
014.txt AC 15 ms 3952 KB
015.txt AC 17 ms 3808 KB
016.txt AC 17 ms 3888 KB
017.txt AC 20 ms 3840 KB
018.txt AC 16 ms 3796 KB
019.txt AC 19 ms 3924 KB
020.txt AC 16 ms 3956 KB
021.txt AC 4 ms 3444 KB
022.txt AC 6 ms 3388 KB
023.txt AC 20 ms 3908 KB
example0.txt AC 2 ms 3412 KB
example1.txt AC 2 ms 3412 KB