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:新手,不明白,能得出正确的结果,为什么是wrong answer

Posted by qiyifeijiayou at 2011-11-19 17:38:43 on Problem 1611
In Reply To:新手,不明白,能得出正确的结果,为什么是wrong answer Posted by:michaelhsuke at 2011-10-27 10:57:06
> 我的源代码
> 
> #include <stdio.h>
> 
> int List[500][30001];
> int n,m,index=1;
> int rec[30001];
> int visited[500];
> 
> 
> void insertRec(int i) //用i组的所有成员都加入怀疑对象数组
> {
> 	int j;
> 	rec[0]+=List[i][0];
> 	for(j=1;j<=List[i][0];j++)
> 	{
> 		rec[index++]=List[i][j];
> 	}
> }
> 
> int searchInList(int x,int i)	//第i组中是否存在x
> {
> 	int j;
> 	for(j=1;j<=List[i][0];j++)
> 		if(x==List[i][j])
> 			return 1;
> 
> 	return 0;
> }
> 	
> 
> 	
> 
> void input(int m)	//输入数据
> {
> 	int i,j,nMembers;
> 	for(i=0;i<m;i++)
> 	{
> 		visited[i]=0;
> 		scanf("%d",&nMembers);
> 		List[i][0]=nMembers;
> 		for(j=1;j<=nMembers;j++)
> 		{
> 			scanf("%d",&List[i][j]);
> 			if(List[i][j]==0)
> 			{
> 				visited[i]=1;
> 				rec[0]+=(List[i][0]-1);
> 				insertRec(i);
> 			}
> 		}
> 	}
> }
> 
> 
> void main()		//主程序
> {
> 	int finish,i,j;
> 	while(scanf("%d %d",&n,&m))
> 	{
> 		if((n==0)&&(m==0))
> 			return;
> 		if((n==1)&&(m==0))
> 		{
> 			printf("%d\n",n);
> 			continue;
> 		}
> 		
> 		finish=0;
> 		rec[0]=1;
> 		input(m);
> 		while(!finish)
> 		{
> 			finish=1;
> 			for(i=0;i<m;i++)
> 			{
> 				if(visited[i]==0)
> 				{				
> 					for(j=1;j<index;j++)
> 					{
> 						if(searchInList(rec[j],i))
> 						{
> 							finish=0;
> 							visited[i]=1;
> 							insertRec(i);
> 							break;
> 						}
> 					}
> 				}
> 			}
> 		}
> 		printf("%d\n",rec[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