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:TLE啊,哪位高手帮忙看一下!谢了!

Posted by vivill at 2006-04-03 12:49:23 on Problem 1166
In Reply To:TLE啊,哪位高手帮忙看一下!谢了! Posted by:vivill at 2006-03-24 14:03:15
> #include<iostream.h>
> #include<string.h>
> int d[9],c[9];
> void main()
> {
> 	int begin[9],temp[9];
> 	char *a[9]={"ABDE","ABC","BCEF","ADG","BDEFH","CFI","DEGH","GHI","EFHI"};
> 	char b[9]={'A','B','C','D','E','F','G','H','I'};
> 	int s[9];
> 	int i,j,k=0,t=29;
> 	for(i=0;i<9;i++)
> 		{
> 			cin>>begin[i];
> 			temp[i]=begin[i];
> 		}
> 	for(s[0]=0;s[0]<=3;s[0]++)
> 	for(s[1]=0;s[1]<=3;s[1]++)
> 	for(s[2]=0;s[2]<=3;s[2]++)
> 	for(s[3]=0;s[3]<=3;s[3]++)
> 	for(s[4]=0;s[4]<=3;s[4]++)
> 	for(s[5]=0;s[5]<=3;s[5]++)
> 	for(s[6]=0;s[6]<=3;s[6]++)
> 	for(s[7]=0;s[7]<=3;s[7]++)
> 	for(s[8]=0;s[8]<=3;s[8]++)
> 	{
> 	 	for(i=0;i<9;i++)
> 			for(int m=0;m<9;m++)
> 				{
> 					char *p=strchr(a[i],b[m]);
> 					if(p!=NULL)	begin[m]=(begin[m]+s[i])%4;
> 				}
> 			
> 		for(i=0;i<9;i++)
> 			if(begin[i]!=0)break;
> 				
> 		if(i==9)
> 		{	
> 			for(int l=0;l<9;l++) k+=s[l];
> 			if(k<t)
> 			{
> 				t=k;
> 				int g=0;
> 				for(int f=0;f<9;f++)
> 				if(s[f]!=0) 
> 				{
> 					d[g]=f+1;
> 					c[g]=s[f];
> 					g++;
> 				}
> 			}
> 		}
> 			k=0;
> 			for(int m=0;m<9;m++)
> 					begin[m]=temp[m];
> 			
> 	}
> 
> for(i=0;i<9&&c[i]!=0;i++)
> for(j=0;j<c[i];j++)
> cout<<d[i]<<" ";
> }

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