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 |
Why tle???{ problem:pku-1002 author:batie date:2003-6-5 ver:1.0 } const fin='1002.in';fout='1002.out'; maxn=100000; var q:array[1..maxn] of string[7]; n,hs:longint; procedure swap(i,j:longint); var t:string[7]; begin t:=q[i];q[i]:=q[j];q[j]:=t; end; procedure down(t:longint); var i:longint; begin repeat i:=t; if (i*2<=hs) and (q[i*2]<q[t]) then t:=i*2; if (i*2+1<=hs) and (q[i*2+1]<q[t]) then t:=i*2+1; if i<>t then swap(i,t); until i=t; end; procedure delete; begin q[1]:=q[hs]; dec(hs); down(1); end; procedure init; var i,j:longint; ch:char; begin readln(n); for i:=1 to n do begin q[i]:=' '; j:=0; repeat read(ch); if ch in ['0'..'9'] then begin inc(j); q[i,j]:=ch; end; if ch in ['A'..'Z'] then begin inc(j); case ch of 'A','B','C':q[i,j]:='2'; 'D','E','F':q[i,j]:='3'; 'G','H','I':q[i,j]:='4'; 'J','K','L':q[i,j]:='5'; 'M','N','O':q[i,j]:='6'; 'P','R','S':q[i,j]:='7'; 'T','U','V':q[i,j]:='8'; 'W','X','Y':q[i,j]:='9'; end; end; until j=7; end; hs:=n; for i:=hs downto 1 do down(i); end; procedure main; var tot,j:longint; stan:string[7]; begin while hs>0 do begin stan:=q[1]; tot:=1; delete; while (hs>0) and (q[1]=stan) do begin inc(tot); delete; end; if tot>1 then begin for j:=1 to 3 do write(stan[j]); write('-'); for j:=4 to 7 do write(stan[j]); writeln(' ',tot); end; end; end; begin init; main; end. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator