[Bzoj1299] chocolate bars

In order to facilitate consideration, it may be prescribed only when the current chocolate bars have taken over, in order to get the new chocolate bars
set of the first to take the upper hand and so is S, according to nim game, the upper hand when S is not 0 xor (formerly FLAC) win, they turn first hand the collection, as long as xor has been absent for the collection of 0, eventually losing the upper hand
and then when there is a collection of 0 xor, then take the upper hand will inevitably be done one of the largest sub-xor set, then the rest of the absence of a certain set is a subset xor 0 (otherwise it may be larger), and then into the upper hand win
is determined whether there is a subset of the xor 0 can be used to determine the linear group (of course this violence is also OK too small n)

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int n,x,s,a[105];
 4 void add(int x){
 5     for(int i=30;i>=0;i--)
 6         if (x&(1<<i))
 7             if (a[i])x^=a[i];
 8             else{
 9                 s++;
10                 a[i]=x;
11                 break;
12             }
13         
14 }
15 int main(){
16     for(int ii=1;ii<=10;ii++){
17         scanf("%d",&n);
18         s=0;
19         memset(a,0,sizeof(a));
20         for(int i=1;i<=n;i++){
21             scanf("%d",&x);
22             add(x);
23         }
24         if (s<n)printf("NO\n");
25         else printf("YES\n");
26     }
27 }
View Code

 

Guess you like

Origin www.cnblogs.com/PYWBKTDA/p/11832844.html