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:怎么会超时呢?那位高手给点意见。

Posted by buaahanjunwei at 2010-11-18 16:28:39 on Problem 1002
In Reply To:怎么会超时呢?那位高手给点意见。 Posted by:Seraph_fd at 2010-11-18 13:55:38
> #include <iostream>
> using namespace std;
> int main(void)
> {
> 	int i=0,x,j,k;
> 	int a[100000];
> 	int n[100000],m;
> 	char c;
> 	cin>>x;
> 	for(i=0;i<x;i++)
> 		a[i]=0,n[i]=1;
> 	i=0;
> 	j=0;
> 	while(i<7*x)
> 	{
> 		cin>>c;
> 		if(c=='-')
> 			continue;
> 		switch(c)
> 		{
> 		case '0':i++;a[j]=a[j]*10;break;
> 		case '1':i++;a[j]=a[j]*10+1;break;
> 		case '2':
> 		case 'A':
> 		case 'B':
> 		case 'C':i++;a[j]=a[j]*10+2;break;
> 		case '3':
> 		case 'D':
> 		case 'E':
> 		case 'F':i++;a[j]=a[j]*10+3;break;
> 		case '4':
> 		case 'G':
> 		case 'H':
> 		case 'I':i++;a[j]=a[j]*10+4;break;
> 		case '5':
> 		case 'J':
> 		case 'K':
> 		case 'L':i++;a[j]=a[j]*10+5;break;
> 		case '6':
> 		case 'M':
> 		case 'N':
> 		case 'O':i++;a[j]=a[j]*10+6;break;
> 		case '7':
> 		case 'P':
> 		case 'R':
> 		case 'S':i++;a[j]=a[j]*10+7;break;
> 		case '8':
> 		case 'T':
> 		case 'U':
> 		case 'V':i++;a[j]=a[j]*10+8;break;
> 		case '9':
> 		case 'W':
> 		case 'X':
> 		case 'Y':i++;a[j]=a[j]*10+9;break;
> 		default:break;
> 		}
> 		if(i%7==0)
> 			j++;
> 	}
> 	for(i=0;i<x-1;i++)
> 		for(j=i+1;j<x;j++)
> 			if(a[i]==a[j])
> 				n[i]++,a[j]=j;
> 	for(i=0;i<x-1;i++)
> 		for(j=i+1;j<x;j++)
> 			if(a[i]>a[j])
> 			{
> 				k=a[i];
> 				a[i]=a[j];
> 				a[j]=k;
> 				m=n[i];
> 				n[i]=n[j];
> 				n[j]=m;
> 			}
> 	j=0;
> 	for(i=0;i<x;i++)
> 		if(n[i]>1)
> 		{
> 			j++;
> 			cout<<a[i]/1000000<<a[i]/100000<<a[i]/10000<<"-"<<a[i]%10000<<" "<<n[i]<<endl;
> 		}
> 	if(j==0)
> 		cout<<"No duplicates."
> 	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