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

你的测试文件有这里的测试文件大吗?

Posted by Sempr at 2007-02-11 16:04:54 on Problem 1002
In Reply To:Confused! Posted by:xh176233756 at 2007-02-11 16:02:25
> #define A(k) p[i].string[k]
> #include "string.h"
> #include "malloc.h"
> #include "stdio.h"
> struct num
> {
> 	char string[20];
> 	int dt;
> 	int flag;
> };
> int main()
> {
> 	int n,i,j,k,*q,v,total;
> 	struct num *p;
> 	scanf("%d",&n);total=n;
> 	p=(struct num *)calloc(n,sizeof(struct num));
> 	for(i=0;i<n;i++)
> 	{
> 		scanf("%s",p[i].string);
> 		for(j=0,k=0;A(j)!='\0';j++,k++)
> 			if(A(j)>47&&A(j)<58)A(k)=A(j);
> 			else switch(A(j))
> 			{case 'A':A(k)='2';break;
> 			 case 'B':A(k)='2';break;
> 			 case 'C':A(k)='2';break;
> 			 case 'D':A(k)='3';break;
> 			 case 'E':A(k)='3';break;
> 			 case 'F':A(k)='3';break;
> 			 case 'G':A(k)='4';break;
> 			 case 'H':A(k)='4';break;
> 			 case 'I':A(k)='4';break;
> 			 case 'J':A(k)='5';break;
> 			 case 'K':A(k)='5';break;
> 			 case 'L':A(k)='5';break;
> 			 case 'M':A(k)='6';break;
> 			 case 'N':A(k)='6';break;
> 			 case 'O':A(k)='6';break;
> 			 case 'P':A(k)='7';break;
> 			 case 'R':A(k)='7';break;
> 			 case 'S':A(k)='7';break;
> 			 case 'T':A(k)='8';break;
> 			 case 'U':A(k)='8';break;
> 			 case 'V':A(k)='8';break;
> 			 case 'W':A(k)='9';break;
> 			 case 'X':A(k)='9';break;
> 			 case 'Y':A(k)='9';break;
> 			 default:k--; }
> 			A(k)='\0';
> 			p[i].dt=1;
> 			p[i].flag=1;}
> 	for(i=0;i<n-1;i++)
> 		if(p[i].flag)
> 			for(j=i+1;j<n;j++)
> 				if(!strcmp(p[i].string,p[j].string)&&p[j].flag)
> 				{
> 					p[i].dt++;
> 					p[j].flag=0;
> 					total--;
> 				}
> 	if(total-n)
> 		{
> 			q=(int *)calloc(total,sizeof(int));
> 			j=0;
> 			for(i=0;i<n;i++)
> 				if(p[i].dt-1){q[j]=i;j++;}
> 			for(i=0;i<j-1;i++)
> 				for(k=i+1;k<j;k++)
> 					if(strcmp(p[q[i]].string,p[q[k]].string)>0)
> 						{v=q[i];q[i]=q[k];q[k]=v;}
> 			for(i=0;i<j;i++)
> 			{
> 				for(k=0;k<3;k++)printf("%c",p[q[i]].string[k]);
> 				printf("-");
> 				for(k=3;k<7;k++)printf("%c",p[q[i]].string[k]);
> 				printf(" %d\n",p[q[i]].dt);
> 			}
> 		}
> 	else printf("No duplicates.\n");
> 	return 0;
> }
> 
> 
> 为什么TLE啊?我觉得不到2秒啊?

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