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 |
Re:不用并查集可不可以做?In Reply To:Re:不用并查集可不可以做? Posted by:380030144 at 2013-03-24 00:12:27 > #include<iostream> > #include<stdio.h> > #include<string.h> > #include<algorithm> > #include<stdlib.h> > #include<math.h> > using namespace std; > int pre[500500]; > int max(int x,int y) > { > int i=x>y?x:y; > return i; > } > int main() > { > int i,j=0; > int n; > long long int m; > int x,y; > int tmp=0; > int sum=0; > while(1) > { > j++; > sum=0; > scanf("%d",&n); > cin>>m; > if(n==0) > break; > memset(pre,0,sizeof(pre)); > // printf("%d\n",pre[2]); > for(i=0;i<m;i++) > { > scanf("%d %d",&x,&y); > if(x!=y && x!=0 && y!=0) > { > tmp=max(x,y); > pre[tmp]=1; > } > } > for(i=1;i<=n;i++) > { > if(pre[i]==0) > sum++; > } > printf("Case %d: %d\n\n",j,sum); > } > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator