A. Submission Bait
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output
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 1≤i≤n) such that a i ≥ m x a_{i} \geq mx ai≥mx 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.
Input
The first line contains an integer t t t ( 1 ≤ t ≤ 1 0 3 1 \leq t \leq 10^3 1≤t≤103) — the number of test cases.
For each test case:
- The first line contains an integer n n n ( 2 ≤ n ≤ 50 2 \leq n \leq 50 2≤n≤50) — the size of the array.
- The second line contains
n
n
n integers
a
1
,
a
2
,
…
,
a
n
a_1, a_2, \ldots, a_n
a1,a2,…,an (
1
≤
a
i
≤
n
1 \leq a_i \leq n
1≤ai≤n) — the elements of the array.
Output
For each test case, if Alice has a winning strategy, output “YES”. Otherwise, output “NO”.
You can output the answer in any case (upper or lower). For example, the strings “yEs”, “yes”, “Yes”, and “YES” will be recognized as positive responses.
Example
input
5
2
2 1
2
1 1
3
3 3 3
4
3 3 4 4
4
1 2 2 2
output
YES
NO
YES
NO
YES
Note
In the first test case, Alice can choose i = 1 i=1 i=1 since a 1 = 2 ≥ m x = 0 a_1=2 \ge mx=0 a1=2≥mx=0.
After Alice’s operation, a = [ 0 , 1 ] a=[0,1] a=[0,1] and m x = 2 mx=2 mx=2. Bob can not do any operation. Alice wins.
In the second test case, Alice doesn’t have a winning strategy.
For example, if Alice chooses
i
=
1
i=1
i=1, after Alice’s operation:
a
=
[
0
,
1
]
a=[0,1]
a=[0,1] and
m
x
=
1
mx=1
mx=1. Then, Bob can choose
i
=
2
i=2
i=2 since
a
2
=
1
≥
m
x
=
1
a_2=1 \ge mx=1
a2=1≥mx=1. After Bob’s operation:
a
=
[
0
,
0
]
a=[0,0]
a=[0,0] and
m
x
=
1
mx=1
mx=1. Alice can not do any operation. Bob wins.
###思路:排序之后从最大到最小只要个数是奇数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;
}