Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

TLE了,在HUST的OJ是AC的啊,大牛帮忙看看

Posted by galaxy at 2006-02-15 05:50:52 on Problem 1035
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator