|
|
back to boardwa on test 2 please help ... Posted by amirani 22 Sep 2011 19:05 i've got wa on test2. In fact my algo is very simple and a know that this program want another algo but can't understand why this algo don't work... var n,x:int64; s,t:array [1..250000] of char; bool:boolean; i,j:longint; begin readln (n); for i:=1 to n-1 do read (s[i]); readln (s[n]); for i:=1 to n-1 do read (t[i]); readln (t[n]); x:=-1; for i:=1 to n do if s[i]=t[1] then begin bool:=true; for j:=2 to n-i+1 do if s[j+i-1]<>t[j] then begin bool:=false; break; end; if bool then for j:=1 to i-1 do if s[j]<>t[n-i+j+1]then begin bool:=false; break; end; if bool then begin x:=n-i+1; break; end; end; writeln (x); end. Regards Thefox Re: wa on test 2 please help ... Posted by Noob 1 Oct 2011 20:32 In test 2 strings are equal and you should output 0, not n. Anyway your algorithm gets TLE on test: 250000 aaa...aaa aaa...aab Edited by author 01.10.2011 20:35 Re: wa on test 2 please help ... Thanks that helped me :) |
|
|