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???求助 对拍过了程序答案是对的。var book,q:array [1..1000] of string; m,n,ans,i,j,k,tot:longint; t1,t2:string; procedure swap(var a,b:string); var t:string; begin t:=a; a:=b; b:=t; end; procedure qsort1(l,r:longint); var il,ir:longint; mid:string; begin il:=l; ir:=r; mid:=book[(l+r) shr 1]; repeat while book[il]<mid do inc(il); while book[ir]>mid do dec(ir); if il<=ir then begin swap(book[il],book[ir]); inc(il); dec(ir); end; until il>ir; if il<r then qsort1(il,r); if ir>l then qsort1(l,ir); end; procedure qsort2(l,r:longint); var il,ir:longint; mid:string; begin il:=l; ir:=r; mid:=q[(l+r) shr 1]; repeat while q[il]<mid do inc(il); while q[ir]>mid do dec(ir); if il<=ir then begin swap(q[il],q[ir]); inc(il); dec(ir); end; until il>ir; if il<r then qsort2(il,r); if ir>l then qsort2(l,ir); end; begin readln(m,n); for i:=1 to m do readln(book[i]); for i:=1 to n do readln(q[i]); qsort1(1,m); qsort2(1,n); ans:=0; i:=1; j:=1; while (i<=m) and (j<=n) do begin t1:=copy(book[i],1,length(q[j])); t2:=q[j]; if t1=t2 then begin tot:=0; for k:=j to n do begin t1:=copy(book[i],1,length(q[k])); t2:=q[k]; if t1<>t2 then break; inc(tot); end; inc(ans,tot); inc(i); j:=k; if (j=n) and (t1=t2) then inc(j); end else if t1<t2 then inc(i) else if t1>t2 then inc(j); end; writeln(ans); end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator