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 13482 at 2012-07-28 19:24:03 on Problem 1002 and last updated at 2012-07-29 19:22:18
#include<stdio.h>
#include<string.h>
char Ato1(char c)				//转换成数字
{
	switch(c)
	{
	case 'A':case 'B':case 'C':return 50;break;
	case 'D':case 'E':case 'F':return 51;break;
	case 'G':case 'H':case 'I':return 52;break;
	case 'J':case 'K':case 'L':return 53;break;
	case 'M':case 'N':case 'O':return 54;break;
	case 'P':case 'R':case 'S':return 55;break;
	case 'T':case 'U':case 'V':return 56;break;	
	case 'W':case 'X':case 'Y':return 57;break;
	}
}
void main()
{
	char a[100000][8];
	int n,i,j,k,m;
	char c;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		j=0;
		while(j<7)
		{
			c=getchar();
			if((c>47&&c<58))
			{
				a[i][j]=c;            //输入
				j++;
			}
			else if(c>='A'&&c<='Y')
			{
				a[i][j]=Ato1(c);
				j++;
			}
		}
		a[i][7]=1;
	}
	for(i=0;i<n-1;i++)
	{			
		for(m=1;m+i<n;m++)
		{
			j=0;
			for(k=0;k<7;k++)
				if(a[i][k]==a[i+m][k])
					j++;           //数据是否全等
			if(j==7&&a[i][7]!=0&&a[i+m][7]!=0)//0表示重复过了
			{
				a[i][7]+=1;        //记录重复都少次         
				a[m+i][7]=0;      //改变最后一位记录是否重复
			}
			else if(j!=7&&a[i][j+1]>a[i+m][j+1])
				for(j=0;j<8;j++)
				{
					k=a[i][j];
					a[i][j]=a[i+m][j];//排序
					a[i+m][j]=k;
				}
		}
	}
	for(i=0;i<n;i++)
	{
		if(a[i][7]>1)
		{
			m=999;
			for(j=0;j<7;j++)
			{
				if(j==3)             // 输出
					printf("-");
				printf("%c",a[i][j]);
			}
			printf(" %d\n",a[i][7]);
		}
	}
	if(m!=999)
		printf("ds\n");
}

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