Submission #1247829
Source Code Expand
#include <bits/stdc++.h>
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl
#define pb emplace_back
#define fi first
#define se second
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }
ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }
// head
int n;
int a[100010];
int ans;
int res;
bool r[64];
int main(){
n = in();
REP( i , n ){
a[i] = in();
res ^= a[i];
REP( j , 32 ){
if( a[i] & PW(j) ){
r[j] = true;
break;
}
}
}
for( int i = 30; i >= 0; i-- ){
if( res & PW(i) ){
if( r[i] ){
ans++;
res = res ^ ( PW(i) - 1 );
} else {
puts( "-1" );
return 0;
}
}
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Cheating Nim |
User |
vjudge1 |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
1909 Byte |
Status |
AC |
Exec Time |
14 ms |
Memory |
640 KB |
Compile Error
./Main.cpp: In function ‘ll in()’:
./Main.cpp:45:47: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
^
./Main.cpp: In function ‘std::string stin()’:
./Main.cpp:46:66: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }
^
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 |
1 ms |
256 KB |
001.txt |
AC |
1 ms |
256 KB |
002.txt |
AC |
14 ms |
640 KB |
003.txt |
AC |
7 ms |
512 KB |
004.txt |
AC |
6 ms |
384 KB |
005.txt |
AC |
5 ms |
384 KB |
006.txt |
AC |
14 ms |
640 KB |
007.txt |
AC |
14 ms |
640 KB |
008.txt |
AC |
14 ms |
640 KB |
009.txt |
AC |
14 ms |
640 KB |
010.txt |
AC |
14 ms |
640 KB |
011.txt |
AC |
14 ms |
640 KB |
012.txt |
AC |
14 ms |
640 KB |
013.txt |
AC |
14 ms |
640 KB |
014.txt |
AC |
14 ms |
640 KB |
015.txt |
AC |
14 ms |
640 KB |
016.txt |
AC |
14 ms |
640 KB |
017.txt |
AC |
14 ms |
640 KB |
018.txt |
AC |
14 ms |
640 KB |
019.txt |
AC |
14 ms |
640 KB |
020.txt |
AC |
14 ms |
640 KB |
021.txt |
AC |
2 ms |
256 KB |
022.txt |
AC |
2 ms |
256 KB |
023.txt |
AC |
14 ms |
640 KB |
example0.txt |
AC |
1 ms |
256 KB |
example1.txt |
AC |
1 ms |
256 KB |