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#include<stdio.h> int p[30001]; int find(int k){ if(p[k]!=k) p[k]=find(p[k]); return p[k]; } void Suspect(){ int student_num=0,group_num=0,i=0,j=0,k=0,m=0,n=0,temp=0,count=1;/*j is the number of per group,k is the first student number of every group*/ scanf("%d %d",&student_num,&group_num); while(student_num!=0){ for(m=0;m<30001;m++) p[m]=m; count=1; for(i=0;i<group_num;i++){ scanf("%d",&j); scanf("%d",&k); for(m=1;m<j;m++){ scanf("%d",&n); temp=find(n); p[temp]=k; }/*for*/ }/*for*/ for(m=0;m<30001;m++) find(m); temp=p[0]; for(m=1;m<30001;m++){ if(p[m]==temp) count++; } printf("%d ",count); scanf("%d %d",&student_num,&group_num); }/*while*/ } int main(){ Suspect(); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator