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:求各位大神指点一下,一直都是超时。。超时。。在此谢过了In Reply To:求各位大神指点一下,一直都是超时。。超时。。在此谢过了 Posted by:Sponge_JJ at 2013-05-09 10:05:18 > #include <iostream> > #include <cstring> > #include <cstdlib> > #include <algorithm> > using namespace std; > int main() > { > long n; > cin>>n; > string a[100001]; > string b[100001]; > long c[100001]; > for(long i=0;i<n;i++) > { > int k=0; > cin>>a[i]; > int len=a[i].length(); > for(long j=0;j<len;j++) > { > if(a[i][j]=='0') > { > b[i][k]='0'; > k++; > } > else if(a[i][j]=='1') > { > b[i][k]='1'; > k++; > } > else if(a[i][j]=='A'||a[i][j]=='B'||a[i][j]=='C'||a[i][j]=='2') > { > b[i][k]='2'; > k++; > } > else if(a[i][j]=='D'||a[i][j]=='E'||a[i][j]=='F'||a[i][j]=='3') > { > b[i][k]='3'; > k++; > } > else if(a[i][j]=='G'||a[i][j]=='H'||a[i][j]=='I'||a[i][j]=='4') > { > b[i][k]='4'; > k++; > } > else if(a[i][j]=='J'||a[i][j]=='K'||a[i][j]=='L'||a[i][j]=='5') > { > b[i][k]='5'; > k++; > } > else if(a[i][j]=='M'||a[i][j]=='N'||a[i][j]=='O'||a[i][j]=='6') > { > b[i][k]='6'; > k++; > } > else if(a[i][j]=='P'||a[i][j]=='R'||a[i][j]=='S'||a[i][j]=='7') > { > b[i][k]='7'; > k++; > } > else if(a[i][j]=='T'||a[i][j]=='U'||a[i][j]=='V'||a[i][j]=='8') > { > b[i][k]='8'; > k++; > } > else if(a[i][j]=='X'||a[i][j]=='Y'||a[i][j]=='W'||a[i][j]=='9') > { > b[i][k]='9'; > k++; > } > else > { > continue; > } > } > c[i]=atol(b[i].c_str()); > } > sort(c,c+n); > long num=0; > int flag=0; > for(long i=0;i<n-1;i++) > { > if(c[i]==c[i+1]) > { > num++; > } > else > { > if(num>=1) > { > cout<<c[i]<<" "<<num+1<<endl; > num=0; > flag=1; > } > } > } > if(flag==0) > { > 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