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:请问各位大牛,超时是咋回事呢,我是用PASCAL编的In Reply To:请问各位大牛,超时是咋回事呢,我是用PASCAL编的 Posted by:gaobicheng at 2010-07-08 21:29:28 var n,i,j,k,x:longint; s:string; a:array[1..100000] of string; new:array[1..1001] of string; w:array[1..1001] of longint; procedure change(var s:string); var i,j,k,l:longint; s1,s2:string; begin l:=length(s); s1:=''; i:=1; while i<=l do begin if (i=4)and(s[i]<>'-') then begin s1:=s1+'-'; s2:='-'; insert(s2,s,4); inc(i); inc(l); end else begin case s[i] of 'A','B','C':s1:=s1+'2'; 'D','E','F':s1:=s1+'3'; 'G','H','I':s1:=s1+'4'; 'J','K','L':s1:=s1+'5'; 'M','N','O':s1:=s1+'6'; 'P','R','S':s1:=s1+'7'; 'T','U','V':s1:=s1+'8'; 'W','X','Y':s1:=s1+'9'; '1','2','3','4','5','6','7','8','9','0':s1:=s1+s[i]; '-':if i=4 then s1:=s1+s[i] end; if ((i<>4)and(s[i]='-'))then begin delete(s,i,1); dec(l); end else inc(i); end; end; s:=s1; end; begin readln(n); for i:=1 to n do begin readln(s); change(s); a[i]:=s; end; x:=0; for i:=1 to n do begin s:=a[i]; if s<>'' then begin k:=0; for j:=1 to n do if s=a[j] then begin inc(k); a[j]:=''; end; if k<>1 then begin inc(x); new[x]:=s; w[x]:=k; end; end; end; for i:=1 to x-1 do for j:=i+1 to x do begin if new[i]>new[j] then begin s:=new[i]; new[i]:=new[j]; new[j]:=s; k:=w[i]; w[i]:=w[j]; w[j]:=k; end; end; if x=0 then writeln('No duplicates.') else for i:=1 to x do writeln(new[i],' ',w[i]); end. 请问怎么会超时啊 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator