标签:block ++ otherwise clu inpu its tom blog else
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 2605 Accepted Submission(s): 1092
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cstdlib> 5 #include <cstring> 6 #include <cmath> 7 using namespace std; 8 int sg[(1<<20)+1000]; 9 int main(){ 10 11 12 for(int i = 1;i < (1<<20); i++){ 13 int h[25]; 14 memset(h, -1, sizeof(h)); 15 int last = -1; 16 for(int j = 0; j < 20; j++){ 17 18 if(!((i >> j) & 1)) 19 last = j; 20 if(((i >> j) & 1)){ 21 if(last != -1){ 22 h[sg[(i ^ (1 << j)) ^ (1 << last)]]=1; 23 } 24 } 25 } 26 int j=0; 27 while(h[j] != -1) j++; 28 sg[i]=j; 29 } 30 int T; 31 scanf("%d", &T); 32 while(T--){ 33 int n, tmp, m, ans=0; 34 scanf("%d", &n); 35 for(int i = 1; i <= n; i++){ 36 scanf("%d", &m); 37 tmp = 0; 38 for(int j = 1; j <= m; j++){ 39 int x; 40 scanf("%d", &x); 41 tmp ^= 1 << (20 - x); 42 } 43 ans ^= sg[tmp]; 44 45 } 46 if(ans) 47 puts("YES"); 48 else 49 puts("NO"); 50 } 51 }
标签:block ++ otherwise clu inpu its tom blog else
原文地址:http://www.cnblogs.com/87hbteo/p/7124484.html