Codeforces Round 960 (Div. 2)

A. Submission Bait

Alice and Bob are playing a game in an array a a a of size n n n.

They take turns to do operations, with Alice starting first. The player who can not operate will lose. At first, a variable m x mx mx is set to 0 0 0.

In one operation, a player can do:

  • Choose an index i i i ( 1 ≤ i ≤ n 1 \le i \le n 1in) such that a i ≥ m x a_{i} \geq mx aimx and set m x mx mx to a i a_{i} ai. Then, set a i a_{i} ai to 0 0 0.

Determine whether Alice has a winning strategy.

思路:排序之后从最大到最小只要个数是奇数Alice就能赢
反思:反思刚开始想到第一个是奇数能赢,后来想到了第一个偶数,第二个是奇数也能赢,很遗憾没想到不止最大的两个数
代码
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		int a[59];
		int b[59]={0};
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
			b[a[i]]++;//计算相同数字的个数
		}
		int f=0;
		sort(a+1,a+n+1);
		for(int i=n;i>=1;i--)
		{
			if(b[a[i]]%2!=0)//只要遇到奇数用f标志
			f=1; 
		}
		if(f%2!=0)
			cout<<"YES"<<'\n';
		else 
			cout<<"NO"<<'\n';
	}
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值