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

这道题怎么做才通过,为什么老是tle

Posted by oracle at 2006-05-29 18:22:15 on Problem 1053
试过好多次了,为什么总是tle,这道题要怎么做?
#include"stdio.h"
#include"string.h"

int main()
{
	char card[20][12][5];
	int i=0,j,k,l;
	int sign;

	int count=0;
	while(gets(card[count][i])&&strlen(card[count][i])){
		for(i=1;i<12;i++)
			gets(card[count][i]);
		getchar();
		i=0;
		count++;
	}
	
	
	
	for(l=0;l<count;l++){

		printf("CARDS:");

		for(i=0;i<12;i++)	printf(" %s",card[l][i]);
		
		printf("\nSETS:");
		
		sign=0;
		
		for(i=0;i<10;i++){
			for(j=i+1;j<11;j++){
				for(k=j+1;k<12;k++){

					if( !(card[l][i][0]^card[l][j][0]) && !(card[l][i][0]^card[l][k][0]) &&
						!(card[l][j][0]^card[l][k][0]) || (card[l][i][0]^card[l][j][0]) &&
						(card[l][i][0]^card[l][k][0]) && card[l][j][0]^card[l][k][0] ) {
					
							if( !(card[l][i][1]^card[l][j][1]) && !(card[l][i][1]^card[l][k][1]) &&
								!(card[l][j][1]^card[l][k][1]) || (card[l][i][1]^card[l][j][1]) &&
								(card[l][i][1]^card[l][k][1]) && card[l][j][1]^card[l][k][1] ) {

									if( !(card[l][i][2]^card[l][j][2]) && !(card[l][i][2]^card[l][k][2]) &&
										!(card[l][j][2]^card[l][k][2]) || (card[l][i][2]^card[l][j][2]) &&
										(card[l][i][2]^card[l][k][2]) && card[l][j][2]^card[l][k][2] ) {

										if( !(card[l][i][3]^card[l][j][3]) && !(card[l][i][3]^card[l][k][3]) &&
											!(card[l][j][3]^card[l][k][3]) || (card[l][i][3]^card[l][j][3]) &&
											(card[l][i][3]^card[l][k][3]) && card[l][j][3]^card[l][k][3] ) {

											if(sign==0)
												printf("  %d. %s %s %s\n",++sign,card[l][i],card[l][j],
													card[l][k]);
											else
												printf("       %d. %s %s %s\n",++sign,card[l][i],card[l][j],
													card[l][k]);
										}
								}
						}
					}							
				}
			}
		}
		if(sign==0) printf("  *** None Found ***\n");
	}
	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