HDU 2509 Be the Winner(取火柴博弈2)

时间:2023-03-09 06:14:09
HDU 2509 Be the Winner(取火柴博弈2)

传送门

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std; int main()
{
int n;
while(~scanf("%d",&n))
{
int a,res=0;
int c=0,g=0;
for(int i=0;i<n;i++)
{
scanf("%d",&a);
if(a>=2) c++;
else if(a==1) g++;
res^=a;
}
if(!res)
{
if(c>=2)//T2
printf("No\n");
else if(c==0)
printf("Yes\n");
}
else//S
{
if(g&1&&c==0)//S0
printf("No\n");
else if(c==1||c>=2)//S1,S2
printf("Yes\n");
}
}
return 0;
}