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 |
TLE!!!In Reply To:Re:给几个数据给大家。借鉴 Posted by:13lazyrainy at 2007-08-05 15:54:30 #include <iostream> #include <string> using namespace std; string s[500000]; char tel1[800000]; char tel[800000]; int main() { int num[50000]={0}; int flag[50000]={0}; int i,i1,j=0,k=0,n,len,w=1,m=0; scanf("%d",&n); for(i=0;i<n;i++) { cin>>s[i]; strcpy(tel1, s[i].c_str() ); len=strlen(tel1); for(int i2=0;i2<len;i2++) { if(tel1[i2]!='-') {tel[j]=tel1[i2]; j++; } } for(i1=0;i1<j;i1++) { if(tel[i1]=='A'||tel[i1]=='B'||tel[i1]=='C') tel[i1]='2'; if(tel[i1]=='D'||tel[i1]=='E'||tel[i1]=='F') tel[i1]='3'; if(tel[i1]=='G'||tel[i1]=='H'||tel[i1]=='I') tel[i1]='4'; if(tel[i1]=='J'||tel[i1]=='K'||tel[i1]=='L') tel[i1]='5'; if(tel[i1]=='M'||tel[i1]=='N'||tel[i1]=='O') tel[i1]='6'; if(tel[i1]=='P'||tel[i1]=='R'||tel[i1]=='S') tel[i1]='7'; if(tel[i1]=='T'||tel[i1]=='U'||tel[i1]=='V') tel[i1]='8'; if(tel[i1]=='W'||tel[i1]=='X'||tel[i1]=='Y') tel[i1]='9'; } s[i]=tel; j=0; } //dianxu string so; for(i=0;i<n;i++) for(j=i+1;j<n;j++) {if(s[i].compare(s[j])>0) {so=s[i]; s[i]=s[j]; s[j]=so; } } for(i=0;i<n;i++) for(j=i+1;j<n;j++) { if(flag[j]!=1&&flag[i]!=1) { if(s[i].compare(s[j])==0) { num[i]++; flag[j]=1; w=0; } } } string sk="-a"; for(i=0;i<n;i++) {if(num[i]>0) { s[i].insert(3,sk,0,1); cout<<s[i]<<" "<<num[i]+1<<endl; } } if(w) cout<<"No duplicates."<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator