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 |
TLE了,在HUST的OJ是AC的啊,大牛帮忙看看program ex1; const maxn=10001; var str:string; var s:array [1..maxn] of string; var rr,i,j,k,n,w1,w2,ii:longint; var st:string; var p,q:boolean; var r:array [1..10001] of string; procedure solve; var s1,s2:string; var s3:string; begin for k:=1 to n do begin if (s[k]=str) then begin s3:=copy(s[k],2,length(s[k])-2); write(s3,' is correct'); q:=true; continue; end; for i:=1 to length(str)-1 do begin s1:=copy(str,1,i); s2:=copy(str,i+1,length(str)-i); w1:=pos(s1,s[k]); w2:=pos(s2,s[k]); if (w1<>0)and(w2<>0)and(w1+length(s1)+1=w2) then begin inc(rr); s3:=copy(s[k],2,length(s[k])-2); r[rr]:=s3; break; end; s1:=copy(str,1,i-1); s2:=copy(str,i+1,length(str)-i); w1:=pos(s1,s[k]); w2:=pos(s2,s[k]); if (w1<>0)and(w2<>0)and (w1+length(s1)+1=w2) then begin inc(rr); s3:=copy(s[k],2,length(s[k])-2); r[rr]:=s3; break; end; if (w1<>0)and(w2<>0)and(w1+length(s1)=w2) then begin inc(rr); s3:=copy(s[k],2,length(s[k])-2); r[rr]:=s3; break; end; end; end; end; begin {assign(input,'in.txt'); reset(input); } repeat readln(st); if st='#' then break; insert(chr(0),st,1); insert(' ',st,length(st)+1); inc(n); s[n]:=st; until (st='#'); p:=true; repeat readln(str); if str='#' then break; insert(chr(0),str,1); q:=false; rr:=0; insert(' ',str,length(str)+1); solve; if (q=false) then begin st:=copy(str,2,length(str)-2); write(st,':'); for ii:=1 to rr do write(' ',r[ii]); end; writeln; until (p=false); end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator