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 |
换成G++AC !!! AC!!!! AC!!! C++格式提交居然WA!#include<iostream> #include<cstdio> #include<cstring> using namespace std; int father[30020]; int fd(int x) { if(father[x]==x) { return x; } fd(father[x]); } int flag; int main() { int n,m,p1,p2; while(~scanf("%d%d",&n,&m)) { flag=0; for(int i=0;i<=n;i++) { father[i]=i; } if(n==0&&m==0) { break; } int g,a,b; while(m--) { scanf("%d%d",&g,&a); while(--g) { scanf("%d",&b); p1=fd(a); p2=fd(b); father[p1]=p2; } } int c; int ans=0; c=fd(father[0]); for(int i=0;i<=n;i++) { if(fd(father[i])==c) { ans++; } } printf("%d\n",ans); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator