Submission #4070373
Source Code Expand
#include<cstdio> #include<algorithm> using namespace std; int n,a[100000],dp[100001][30][2],two[30],x=0,y,cnt=0,f[30]={}; int main(){ scanf("%d",&n); two[0]=2; for(int i=1;i<30;i++){ two[i]=2*two[i-1]; } for(int i=0;i<n;i++){ scanf("%d",&a[i]); x=x^a[i]; y=a[i]^(a[i]-1); for(int j=0;j<30;j++){ if(y+1==two[j]){ f[j]=1; } } } for(int i=29;i>=0;i--){ if(f[i]){ if(x^(two[i]-1)<x){ x=x^(two[i]-1); cnt++; } } } if(x){ printf("-1\n"); } else{ printf("%d\n",cnt); } }
Submission Info
Submission Time | |
---|---|
Task | C - Cheating Nim |
User | AC961009 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 721 Byte |
Status | WA |
Exec Time | 15 ms |
Memory | 512 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:6:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ^ ./Main.cpp:12:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&a[i]); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 128 KB |
001.txt | AC | 1 ms | 128 KB |
002.txt | AC | 15 ms | 512 KB |
003.txt | WA | 7 ms | 384 KB |
004.txt | AC | 7 ms | 384 KB |
005.txt | AC | 5 ms | 256 KB |
006.txt | WA | 15 ms | 512 KB |
007.txt | WA | 15 ms | 512 KB |
008.txt | WA | 15 ms | 512 KB |
009.txt | WA | 15 ms | 512 KB |
010.txt | WA | 15 ms | 512 KB |
011.txt | WA | 15 ms | 512 KB |
012.txt | WA | 15 ms | 512 KB |
013.txt | WA | 15 ms | 512 KB |
014.txt | WA | 15 ms | 512 KB |
015.txt | WA | 15 ms | 512 KB |
016.txt | AC | 15 ms | 512 KB |
017.txt | AC | 15 ms | 512 KB |
018.txt | WA | 15 ms | 512 KB |
019.txt | WA | 15 ms | 512 KB |
020.txt | AC | 15 ms | 512 KB |
021.txt | AC | 2 ms | 256 KB |
022.txt | AC | 2 ms | 256 KB |
023.txt | AC | 14 ms | 512 KB |
example0.txt | AC | 1 ms | 128 KB |
example1.txt | AC | 1 ms | 128 KB |