Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
求助~~哪位牛人帮忙看下,需要改进,Time Limit Exceed#include<iostream.h> #include<string.h> void main(){ int n,i,j,x,k,l=0,m,h,y; char a[50000][20],b[1000][10],s[10]; char num[]="22233344455566677778889999"; int count[]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; cin>>n; for(i=0;i<n;i++){ k=0; cin>>a[i]; for(j=0;a[i][j]!='\0';j++){ if(a[i][j]>='A' && a[i][j]<='Y'){ a[i][j]=num[a[i][j]-'A']; } if(a[i][j]>='0' && a[i][j]<='9'){ b[l][k]=a[i][j]; k++;} } l++; for(x=0;x<l-1;x++){ m=0; for(int e=0;e<7;e++){ if(b[l-1][e]==b[x][e]) m++;} if(m==7){ count[x]++; l--;} } } h=0; for(j=0;j<=x;j++){ if(count[j]>1) h++;} if(h==0){ cout<<"No duplicates."<<endl; } for(h=0;h<=x;h++) { for(k=0;k<7;k++) s[k]=b[0][k]; for(j=1;j<=x;j++){ if(strcmp(s,b[j])>0){ for(k=0;k<7;k++) s[k]=b[j][k]; } } for(j=0;j<=x;j++){ y=0; for(k=0;k<7;k++){ if(s[k]==b[j][k]) y++;} if(y==7) break; } for(k=0;k<7;k++) b[j][k]='9'; if(count[j]>1){ for(k=0;k<3;k++) cout<<s[k]; cout<<"-"; for(;k<7;k++) cout<<s[k]; cout<<" "<<count[j]<<endl;} } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator