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:搞了十二万数据,自己写的代码一点答案都出来了,到百度知道找的答案运了3,4秒才出,我的居然是TIME...,用他的交居然AC,气啊In Reply To:搞了十二万数据,自己写的代码一点答案都出来了,到百度知道找的答案运了3,4秒才出,我的居然是TIME...,用他的交居然AC,气啊 Posted by:yunlong17568 at 2012-03-13 19:17:32 自己写的(提交超时)供大家参考 #include <stdio.h> int main() { int i,j,k,n,y[100000][2],num,zhong,nsign,end,msign,xsign; char z[100000],x[7]; scanf("%d",&n); num=0; xsign=1; for(i=1;i<=n;i++) { scanf("%s",z); for(j=0,k=0;k<=6;j++) { if(z[j]!='-') { x[k]=z[j];k++; } } for(k=0;k<=6;k++) { if(x[k]>='A'&&x[k]<='O') x[k]=(x[k]-59)/3+'0'; if(x[k]=='P'||x[k]=='R'||x[k]=='S') x[k]='7'; if(x[k]>='T'&&x[k]<='Y') x[k]=(x[k]-60)/3+'0'; } zhong=0;nsign=1;msign=1; for(j=0;j<=6;j++) zhong=zhong*10+(x[j]-'0'); for(j=0;j<num;j++) { if(zhong==y[j][0]) { y[j][1]++; nsign=0; } } if(nsign) { for(k=0;k<=num-1;k++) { if(zhong<y[k][0]) { msign=0; for(end=num;end>=k+1;end--) { y[end][0]=y[end-1][0]; y[end][1]=y[end-1][1]; } y[k][0]=zhong;y[k][1]=1; break; } } if(msign) { y[num][0]=zhong; y[num][1]=1; } num++; } } for(i=0;i<=num-1;i++) if(y[i][1]>=2) { printf("%03d-%04d %d\n",y[i][0]/10000,y[i][0]%10000,y[i][1]); xsign=0; } if(xsign) printf("No duplicates.\n"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator