|
|
back to boardTime limit test#10 Why? code pascal program z1; var s, s1:string; n, x:longint; begin readln(n); readln(s); readln(s1); if s=s1 then write(0) else begin s:=s+s; case pos(s1, s) of 1..250000:writeln(n-pos(s1, s)+1); else write(-1); end; end; readln; end. Re: Time limit test#10 Posted by Noob 17 Dec 2012 02:55 Your algorithm is wrong, read more about KMP algorithm or string hashing P.S. Test for you: aaa...aaa aaa...aab |
|
|