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啊?type new=record c:cardinal; x,y:longint; end; const mat:array['A'..'Z']of char=('2','2','2','3','3','3','4','4','4','5','5','5','6','6','6','7','0','7','7','8','8','8','9','9','9','0'); var l,x,y,n,i:longint; a,b,st:string; h:array[1..100000]of new; f:array[0..1000,0..10000]of longint; procedure change(var s:string); var ii:longint; begin for ii:=1 to length(s) do if s[ii] in ['A'..'Z'] then s[ii]:=mat[s[ii]]; end; procedure qsort(l,r:longint); var i,j:longint; x:cardinal; t:new; begin i:=l;j:=r;x:=h[(l+r)shr 1].c; repeat while h[i].c<x do inc(i); while x<h[j].c do dec(j); if i<=j then begin t:=h[i]; h[i]:=h[j]; h[j]:=t; inc(i); dec(j); end; until i>j; if l<j then qsort(l,j); if i<r then qsort(i,r); end; begin fillchar(f,sizeof(f),0); readln(n); l:=0; for i:=1 to n do begin readln(st); while pos('-',st)>0 do delete(st,pos('-',st),1); a:=copy(st,1,3); b:=copy(st,4,4); change(a); change(b); val(a,x);val(b,y); if f[x,y]=0 then begin inc(l); h[l].x:=x;h[l].y:=y;h[l].c:=x*10000+y; inc(f[x,y]); end else inc(f[x,y]); end; if l=0 then writeln('No duplicates.') else begin qsort(1,l); for i:=1 to l do if f[h[i].x,h[i].y]>1 then begin if h[i].x<10 then write('00') else if h[i].x<100 then write(0); write(h[i].x,'-'); if h[i].y<10 then write('000') else if h[i].y<100 then write('00') else if h[i].y<1000then write(0); write(h[i].y,' '); writeln(f[h[i].x,h[i].y]); end; end; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator