Submission #1021915
Source Code Expand
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
using namespace std;
#ifdef DEB
#define dump(x) cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
#endif
template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;
namespace std{
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
out<<'('<<a.fr<<','<<a.sc<<')';
return out;
}
}
//const int INF=5e8;
int n;
bool ar[35];
void ng(){
puts("-1");
exit(0);
}
int main(){
cin>>n;
int sum=0;
REP(i,n){
int a;scanf("%d",&a);
sum^=a;
int d=30;
for(int j=29;j>=0;--j) if(a>>j&1) d=j;
ar[d]=1;
}
int cur=0,res=0;
for(int i=29;i>=0;--i) if((sum>>i&1)!=cur){
if(!ar[i]) ng();
++res;
cur^=1;
}
cout<<res<<endl;
return 0;
}
Submission Info
Submission Time
2016-12-11 18:58:33+0900
Task
C - Cheating Nim
User
hogloid
Language
C++14 (GCC 5.4.1)
Score
500
Code Size
1605 Byte
Status
AC
Exec Time
18 ms
Memory
256 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:57:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int a;scanf("%d",&a);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
500 / 500
Status
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
3 ms
256 KB
001.txt
AC
2 ms
256 KB
002.txt
AC
18 ms
256 KB
003.txt
AC
9 ms
256 KB
004.txt
AC
9 ms
256 KB
005.txt
AC
7 ms
256 KB
006.txt
AC
17 ms
256 KB
007.txt
AC
17 ms
256 KB
008.txt
AC
17 ms
256 KB
009.txt
AC
17 ms
256 KB
010.txt
AC
17 ms
256 KB
011.txt
AC
17 ms
256 KB
012.txt
AC
17 ms
256 KB
013.txt
AC
17 ms
256 KB
014.txt
AC
17 ms
256 KB
015.txt
AC
17 ms
256 KB
016.txt
AC
17 ms
256 KB
017.txt
AC
17 ms
256 KB
018.txt
AC
17 ms
256 KB
019.txt
AC
17 ms
256 KB
020.txt
AC
17 ms
256 KB
021.txt
AC
4 ms
256 KB
022.txt
AC
4 ms
256 KB
023.txt
AC
17 ms
256 KB
example0.txt
AC
2 ms
256 KB
example1.txt
AC
3 ms
256 KB