标签:科学 space ext for sizeof 趣味 博弈 mod 无效
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 215 Accepted Submission(s): 137
B君当然知道怎么做啦!但是他想考考你。
1 #include<cstdio> 2 #include<iostream> 3 #include<cstring> 4 #include<map> 5 #define clr(x) memset(x,0,sizeof(x)) 6 using namespace std; 7 int tree[40010]; 8 map<int,bool> treed; 9 int main() 10 { 11 int T,n,m,u,v,p,w; 12 scanf("%d",&T); 13 while(T--) 14 { 15 scanf("%d%d",&n,&m); 16 clr(tree); 17 treed.clear(); 18 for(int i=1;i<n;i++) 19 { 20 scanf("%d%d%d",&u,&v,&p); 21 if(p==1) 22 { 23 tree[u]++; 24 tree[v]++; 25 treed[u*n+v]=1; 26 treed[v*n+u]=1; 27 } 28 } 29 for(int i=1;i<=m;i++) 30 { 31 scanf("%d",&w); 32 if(w==1) 33 { 34 scanf("%d%d%d",&u,&v,&p); 35 if(p==0 && treed[u*n+v]==1) 36 { 37 tree[u]--; 38 tree[v]--; 39 treed[u*n+v]=0; 40 treed[v*n+u]=0; 41 } 42 43 if(p==1 && treed[u*n+v]==0) 44 { 45 tree[u]++; 46 tree[v]++; 47 treed[u*n+v]=1; 48 treed[v*n+u]=1; 49 } 50 } 51 if(w==0) 52 { 53 scanf("%d",&p); 54 if(tree[p]%2==1) 55 printf("Girls win!\n"); 56 else 57 printf("Boys win!\n"); 58 } 59 } 60 } 61 return 0; 62 }
标签:科学 space ext for sizeof 趣味 博弈 mod 无效
原文地址:http://www.cnblogs.com/wujiechao/p/6147760.html