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 |
为什么是WA???????? 可以帮忙看一下吗?#include<stdio.h> long a[100000],n=0,b[100000]; void input() { long ch[300],m,flag,i,j,k,lc=0,c[100000],num,p; char s[200]; for(i=0;i<300;i++) if(('A'<=i)&&(i<='P'))ch[i]=(i-'A'+6)/3; else if(('R'<=i)&&(i<='Y'))ch[i]=(i-'A'+5)/3; else if(('0'<=i)&&(i<='9'))ch[i]=i-'0'; else ch[i]=0; scanf("%ld",&m); for(i=1;i<=m;i++) { scanf("%s",s); j=0;num=0;p=0; while(s[j]!='\0') { if((ch[s[j]]>0)||(s[j]=='0')){p++;num=num*10+ch[s[j]];} j++; if(p==7)break; } flag=1; for(j=1;j<=n;j++) if(num==a[j]){b[j]=b[j]+1;flag=0;break;} if(flag) { k=lc+1; for(j=1;j<=lc;j++) { if(c[j]==0)k=j; if(num==c[j]) { n=n+1;a[n]=num;b[n]=2; c[j]=0;flag=0;break; } } } if(flag) { if(k>lc)lc=k; c[k]=num; } } } void make(long c[],long c1[],long s) { long i,j,l=0,k=1; while(n-l>2*s) { i=l+1;j=i+s; while((i<=l+s)&&(j<=l+2*s)) if(a[c[i]]>a[c[j]])c1[k++]=c[i++]; else c1[k++]=c[j++]; if(i<=l+s) for(;i<=l+s;i++)c1[k++]=c[i]; else for(;j<=l+2*s;j++) c1[k++]=c[j]; l=l+2*s; } if(n-l>s) { i=l+1;j=i+s; while((i<=l+s)&&(j<=n)) if(a[c[i]]>a[c[j]])c1[k++]=c[i++]; else c1[k++]=c[j++]; if(i<=l+s) for(;i<=l+s;i++)c1[k++]=c[i]; else for(;j<=n;j++) c1[k++]=c[j]; } for(;k<=n;k++)c1[k]=c[k]; } void sort(long c[]) { long s=1,c1[100000]; while(s<n) { make(c,c1,s); s+=s; make(c1,c,s); } } void output(long c[]) { long num,k; if(n==0)printf("No duplicates.\n"); for(;n>0;n--) { num=a[c[n]];k=b[c[n]]; if(num<1000000) { printf("0"); if(num<100000)printf("0%ld-",num/10000); else printf("%ld-",num/10000); } else printf("%ld-",num/10000); num=num%10000; if(num<1000) { printf("0"); if(num<100) { printf("0"); if(num<10)printf("0%ld %ld\n",num,k); else printf("%ld %ld\n",num,k); } else printf("%ld %ld\n",num,k); } else printf("%ld %ld\n",num,k); } } void main() { long c[100000],i; input(); for(i=1;i<=n;i++)c[i]=i; sort(c); output(c); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator