| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
大家帮我看看吧 老是WA 感觉没有错啊#include <iostream> int bug[2000]; int mergecount,bugcount; inline void init(void) { for(int i=0;i<bugcount;++i) bug[i]=i; } int find(int x) { if(x!=bug[x]) bug[x]=find(bug[x]); return bug[x]; } bool merge(int x,int y) { static int xx,yy; xx=find(x); yy=find(y); if(xx==yy) return false; bug[yy]=xx; return true; } int main(void) { int round,r; int i,x,y; bool state; scanf("%d",&round); for(r=1;r<=round;++r) { scanf("%d %d",&bugcount,&mergecount); init(); state=true; if(1==bugcount) state=false; while(mergecount--) { scanf("%d %d",&x,&y); if(state) state=merge(x,y); } if(1==bugcount) state=true; printf("Scenario #%d:\n",r); if(state) printf("No suspicious bugs found!\n"); else printf("Suspicious bugs found!\n"); if(r!=round) printf("\n"); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator