提出 #5498038
ソースコード 拡げる
#include<bits/stdc++.h>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define int long long
using namespace std;
inline void read(int &x)
{
x=0;char ch=getchar();int pd=1;
while(ch<'0'||ch>'9'){if(ch=='-')pd=-pd;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
x*=pd;
}
inline void write(const int &x)
{
char ggg[10001];int s=0;int tmp=x;
if(tmp==0){putchar('0');return;}
if(tmp<0){tmp=-tmp;putchar('-');}
while(tmp>0){ggg[s++]=tmp%10+'0';tmp/=10;}
while(s>0){putchar(ggg[--s]);}
}
int n,ans,a[100010];
int cnt;
bool can[100010];
signed main()
{
read(n);
for(register int i=1;i<=n;++i)
{
read(a[i]);
ans^=a[i];
}
// puts("");
// cout<<ans<<endl;
for(register int i=1;i<=n;++i)
{
for(register int j=0;j<=30;++j)
{
if(a[i]&(1<<j))
{
// cout<<j<<endl;
can[j]=1;
break;
}
}
}
// puts("");
// cout<<ans<<endl;
for(register int i=30;i>=0;--i)
{
// cout<<ans<<" " <<(1<<i)<<" "<<(ans&(1<<i))<<endl;
if(ans&(1<<i))
{
// cout<<i<<endl;
if(!can[i])
{
puts("-1");
return 0;
}
else
{
cnt++;
ans^=(1<<i)-1;
}
}
}
write(cnt);
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - Cheating Nim |
| ユーザ | luogu_bot1 |
| 言語 | C++ (GCC 5.4.1) |
| 得点 | 500 |
| コード長 | 1418 Byte |
| 結果 | AC |
| 実行時間 | 11 ms |
| メモリ | 1024 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 500 / 500 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| 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 |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 000.txt | AC | 1 ms | 256 KiB |
| 001.txt | AC | 1 ms | 256 KiB |
| 002.txt | AC | 10 ms | 1024 KiB |
| 003.txt | AC | 4 ms | 768 KiB |
| 004.txt | AC | 5 ms | 640 KiB |
| 005.txt | AC | 4 ms | 512 KiB |
| 006.txt | AC | 11 ms | 1024 KiB |
| 007.txt | AC | 11 ms | 1024 KiB |
| 008.txt | AC | 11 ms | 1024 KiB |
| 009.txt | AC | 11 ms | 1024 KiB |
| 010.txt | AC | 11 ms | 1024 KiB |
| 011.txt | AC | 11 ms | 1024 KiB |
| 012.txt | AC | 11 ms | 1024 KiB |
| 013.txt | AC | 11 ms | 1024 KiB |
| 014.txt | AC | 11 ms | 1024 KiB |
| 015.txt | AC | 11 ms | 1024 KiB |
| 016.txt | AC | 11 ms | 1024 KiB |
| 017.txt | AC | 11 ms | 1024 KiB |
| 018.txt | AC | 11 ms | 1024 KiB |
| 019.txt | AC | 11 ms | 1024 KiB |
| 020.txt | AC | 11 ms | 1024 KiB |
| 021.txt | AC | 2 ms | 384 KiB |
| 022.txt | AC | 2 ms | 384 KiB |
| 023.txt | AC | 11 ms | 1024 KiB |
| example0.txt | AC | 1 ms | 256 KiB |
| example1.txt | AC | 1 ms | 256 KiB |