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 |
Re:大牛们帮帮忙啊,为什么老是TIME LIMIT EXCEEDED?In Reply To:大牛们帮帮忙啊,为什么老是TIME LIMIT EXCEEDED? Posted by:lankeyouyin at 2009-10-10 23:46:10 > #include <iostream> > #include <string> > using namespace std; > string s[100002]; > int l[100002]; > int i,j,n; > char c; > int main() > {cin>>n; > for(i=1;i<=n;i++) > {for(j=1;j<=8;j++) > if(j==4)s[i]+="-"; > else > {cin>>c; > if(c=='-')j--; > else if (c=='A' || c=='B' || c=='C')s[i]+= "2"; > else if (c=='D' || c=='E' || c=='F')s[i]+= "3"; > else if (c=='G' || c=='H' || c=='I')s[i]+= "4"; > else if (c=='J' || c=='K' || c=='L')s[i]+= "5"; > else if (c=='M' || c=='N' || c=='O')s[i]+= "6"; > else if (c=='P' || c=='R' || c=='S')s[i]+= "7"; > else if (c=='T' || c=='U' || c=='V')s[i]+= "8"; > else if (c=='W' || c=='X' || c=='Y')s[i]+= "9"; > else if ((c>='0')&&(c<='9'))s[i]+=c; > } > } > for(i=1;i<=n;i++)l[i]=1; > for(i=1;i<=n-1;i++) > for(j=i;j<=n;j++) > if((l[i]!=0)&&(l[j]!=0)) > if(s[i]==s[j]) > {l[i]++; > l[j]--; > } > for(i=1;i<=n-1;i++) > for(j=i;j<=n;j++) > if((l[i]!=0)&&(l[j]!=0)) > if(s[i]>s[j]) > {s[100001]=s[i]; > s[i]=s[j]; > s[j]=s[100001]; > l[100001]=l[i]; > l[i]=l[j]; > l[j]=l[100001]; > } > j=0; > for(i=1;i<=n;i++) > if(l[i]>1){cout<<s[i]<<" "<<l[i]<<endl;j++;} > if(j==0)cout<<"No duplicates."; > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator