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:大牛们,要出人命了In Reply To:大牛们,要出人命了 Posted by:3144046cjc at 2008-02-02 19:49:07 > var count,i,n,pand:longint; > cha:char;ch:string; > a:array[1..100001] of longint; > b:array['0'..'Z']of integer; > > > > procedure qsort(l,r: longint); > var > i,j,x,y: longint; > begin > i:=l; > j:=r; > x:=a[(l+r) div 2]; > repeat > while a[i]<x do > inc(i); > while x<a[j] do > dec(j); > if not(i>j) then > begin > y:=a[i]; > a[i]:=a[j]; > a[j]:=y; > inc(i); > j:=j-1; > end; > until i>j; > if l<j then > qsort(l,j); > if i<r then > qsort(i,r); > end; > > > > procedure print(a,count:longint); > var c,j:longint; > cc:string; > begin c:=a div 10000; > str(c,cc); > for j:=1 to 3-ord(cc[0]) do write('0');write(cc);write('-'); > c:=a mod 10000; > str(c,cc); > for j:=1 to 4-ord(cc[0]) do write('0');writeln(cc,' ',count); > end; > > > > function change(ch:string):longint; > var jin,t,j:longint; > begin jin:=1000000; > t:=0; > for j:=1 to ord(ch[0]) do > if ch[j]<>'-' then begin if (ch[j]>='a') and (ch[j]<='z') then > ch[j]:=char(ord(ch[j])-32); > t:=b[ch[j]]*jin+t; > jin:=jin div 10; > end; > change:=t; > end; > > > > begin > for cha:='0' to '9' do begin b[cha]:=count;inc(count);end; > count:=0; > for cha:='A' to 'Y' do > if cha<>'Q' then begin b[cha]:=(count div 3)+2; > inc(count); > end; > readln(n); > for i:=1 to n do > begin readln(ch); > a[i]:=change(ch); > end; > qsort(1,n); > count:=1; > for i:=2 to n+1 do > if a[i]=a[i-1] then inc(count) > else if count>1 then begin print(a[i-1],count); > count:=1;pand:=1; > end; > if pand=0 then writeln('No duplicates'); > end. > 能想到的数据我都试了,还是wa > 不是超时,而是wa > 怎么回事呢?我自己尝试了三十几个数据,都过了啊!有用pascal大高手讲解一下,感激不尽! > 或者谁能提供几组冷偏的数据吗?谢谢 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator