Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

帮忙看下为什么老是RE

Posted by Moon913 at 2010-03-30 15:32:52 on Problem 1611
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator