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 |
哪错了?#include<iostream.h> #include<stdio.h> #include<string.h> main(){ int m,n,a[50000]={0},b[50000]={-1},i,k,c,d,time=1; while(scanf("%d%d",&n,&m),n!=0&&m!=0){ k=1; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); for(i=0;i<m;i++){ scanf("%d%d",&c,&d); if(a[c]==0&&a[d]==0){ a[c]=k;a[d]=1; b[k]+=2; k++; } else if(a[c]!=0&&a[d]==0) {a[d]=a[c]; b[a[c]]++; } else if(a[d]!=0&&a[c]==0) {a[c]=a[d]; b[a[d]]++; } else if(a[d]!=0&&a[c]!=0&&a[d]!=a[c]){ a[d]=a[c]; n--; } }m=0; for(i=1;i<k;i++) m+=b[i]; printf("case %d: %d\n",time,n-k+1); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator