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:Time Limit Exceed!牛人们!帮帮忙!

Posted by 00 at 2005-03-23 23:16:10 on Problem 1002
In Reply To:Time Limit Exceed!牛人们!帮帮忙! Posted by:00 at 2005-03-23 18:21:55
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int sort(const void *,const void *);
char tel[100000][16],Tel[100000][16];
int *time,*c;
long t,i,j,k,l,z=0;
void main()
{
	scanf("%d",&t);
	time=new int[t];
	c=new int[t];
	for(i=0;i<t;i++)
	{
		scanf("%s",tel[i]);
		c[i]=0;
		for(j=0;j<(int)strlen(tel[i]);j++)
		{
			if(tel[i][j]<81&&tel[i][j]>64)
				tel[i][j]=char(int((tel[i][j]-'A'+1)/3.1)+50);
			if(tel[i][j]>81)
				tel[i][j]=char(int((tel[i][j]-'A')/3.1)+50);
		}
		l=0;
		for(k=0;l<8;k++)
		{
			if(l==3)
			{
				Tel[i][l]='-';
				l++;
				k--;
				continue;
			}
			if(tel[i][k]!='-')
			{
				Tel[i][l]=tel[i][k];
				l++;
			}
		}
	}
	qsort(Tel,t,sizeof(Tel[0]),sort);
	for(i=0;i<t;i++)
	{
		for(k=0;k<t;k++)
		{
			if(!strcmp(Tel[i],Tel[k]))
				c[i]++;
		}
		for(j=0;j<i;j++)
		{
			if(!strcmp(Tel[j],Tel[i]))
				goto loop;
		}
		if(c[i]>1)
		{
			z++;
			printf("%s %d\n",Tel[i],c[i]);
		}
loop:	i++;
		i--;
	}
	if(!z)
		printf("%s\n","No duplicates.");
	delete [] time;
	delete [] c;
}
int sort(const void *a, const void *b)
{
	return (strcmp((char*)a,(char*)b));
}

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