题解:P15320 【MX-X24-T1】「RiOI-7」Ah, It's Yesterday Once More
题目解析
分讨。
注意到
首先
考虑集合中全
- 对于全部选取,放回的数字为
1 ,Bob 赢。 - 对于不全部选取,那么剩下的数字必然含有
0 ,Bob 全部选取必胜。
因此,Bob 必胜。
在下面的讨论中,我们默认排除了全
集合中没有
集合中有一个
但是,Alice 不是必胜。如果集合中只有
因此,若集合中有一个
集合中有两个
三个
分讨完毕。
正解代码
#include<bits/stdc++.h>
#define int long long
using namespace std;
//Alice
//Bob
signed main()
{
int t;
cin>>t;
while(t--)
{
int n,cnt=0;
cin>>n;
for(int i=1;i<=n;i++)
{
int ai;cin>>ai;
if(ai==0) cnt++; //0的数量
}
if(n==1) //只有1个数,直接判断输赢
{
if(cnt!=0) cout<<"Alice\n";
else cout<<"Bob\n";
continue;
}
if(cnt==n) //全是0,Bob 必胜
{
cout<<"Bob\n";
continue;
}
if(cnt==0) //无0,Alice 必胜
{
cout<<"Alice\n";
continue;
}
if(cnt==1) //1个0看情况
{
if(n==2) cout<<"Bob\n"; //2个Bob必胜
else cout<<"Alice\n"; //否则Alice必胜
continue;
}
cout<<"Alice\n";//更多的0,Alice 必胜
}
return 0;
}