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 |
怎么会超时呢?那位高手给点意见。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator