ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

Question C
Posted by Remington OKTL 11 Feb 2006 15:37
That's my source, it's only 125000 operation maximum, but is got MLE#8, WHY ???????????

var a,t,ta,tt:string;
    n,i,ans:longint;

begin
readln(n);
ans:=-1;
readln(a);
readln(t);
ta:=a;tt:=t;

for i:=1 to (n div 2+1) do
    begin
    if a<>t then
       begin
       a:=a+a[1];delete(a,1,1);
       end else
           begin
           ans:=n-i+1;
           break;
           end;

    if ta<>tt then
       begin
       tt:=tt+tt[1];delete(tt,1,1);
       end else
           begin
           ans:=i-1;
           break;
           end;

    end;

writeln(ans mod n);
end.