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

讨论一下,能者多劳呀 。。time limited error 有时注定,听君(能者为君)一席话,胜读十年书呀 。多谢指教

Posted by iowyh at 2005-07-28 15:25:22 on Problem 1282
#include<stdio.h>
void main(){
	  int i,j,a,b,flag,x;
	  long count=1;
	int n[2][201],p[201][201];
	scanf("%d%d",&i,&j);
		
	for(a=1;a<=i;a++){n[0][a]=a;}
	
	for(a=1;a<=i;a++)
	{scanf("%d",&p[a][1]);
	scanf("%d",&p[a][0]);
	for(b=j-1;b>=2;b--)
	 scanf("%d",&p[a][b]);
		
	}
		
	while(1){flag=1;x=0;
		for(a=1;a<=i;a++){
			if(flag)
				if(n[(count+1)%2][a]==p[a][count%3])
					x++;
				else flag=0;

			n[count%2][p[a][count%3]]=n[(count+1)%2][a];
			
		}
		if(x==i) { printf("%ld\n",count); break;}
		if(count>1000000000) printf("No one knows.");  
		count++;
	}
}


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