Submission #1000731
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit ) for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define sz(a) int((a).size())
#define all(a) a.begin(), a.end()
#define debug(ccc) cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;
ll power(ll a,ll n){
if(n==0){
return 1;
}
ll b = power(a,n/2);
b = b*b%mod;
if(n%2) b= b*a%mod;
return b;
}
int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}
int v[30];
int main(){
int n,flag=0,y=0,x,ans=0;
scanf("%d",&n);
REP(i,n)
{
scanf("%d",&x);
y^=x;
REP(i,30)
{
if (x&(1<<i))
{
v[i]++;
break;
}
}
}
while(y&&!flag)
{
for(int i=29;i>=0;i--)
{
if (y&(1<<i))
{
if (v[i])
{
ans++;
y^=(1<<i);
y^=(1<<i)-1;
}
else {flag=1; break;}
}
}
}
if (flag) printf("-1\n");
else printf("%d\n",ans);
return 0;
}
Submission Info
Submission Time
2016-11-28 12:41:15+0900
Task
C - Cheating Nim
User
alecsyde
Language
C++14 (GCC 5.4.1)
Score
500
Code Size
1613 Byte
Status
AC
Exec Time
16 ms
Memory
256 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:46:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:49:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&x);
^
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
2 ms
256 KB
001.txt
AC
3 ms
256 KB
002.txt
AC
15 ms
256 KB
003.txt
AC
8 ms
256 KB
004.txt
AC
8 ms
256 KB
005.txt
AC
6 ms
256 KB
006.txt
AC
16 ms
256 KB
007.txt
AC
16 ms
256 KB
008.txt
AC
16 ms
256 KB
009.txt
AC
16 ms
256 KB
010.txt
AC
16 ms
256 KB
011.txt
AC
16 ms
256 KB
012.txt
AC
16 ms
256 KB
013.txt
AC
16 ms
256 KB
014.txt
AC
16 ms
256 KB
015.txt
AC
16 ms
256 KB
016.txt
AC
16 ms
256 KB
017.txt
AC
16 ms
256 KB
018.txt
AC
16 ms
256 KB
019.txt
AC
16 ms
256 KB
020.txt
AC
16 ms
256 KB
021.txt
AC
4 ms
256 KB
022.txt
AC
4 ms
256 KB
023.txt
AC
16 ms
256 KB
example0.txt
AC
3 ms
256 KB
example1.txt
AC
3 ms
256 KB