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

Discussion of Problem 1423. String Tale

Why Compilation Error???
Posted by Assassin 15 Jan 2008 16:03
type vector=array[0..750000] of longint;
     long_string=array[1..500000] of char;

var n:longint;
    s,t:long_string;
    i:longint;

function qqq(s,t:long_string; n:longint):longint;
  var f:vector;
      k,i:longint;
      result:longint;
  begin
    result:=-1;
    f[1]:=0;
    k:=0;
    for i:=2 to n do
      begin
        while (k>0) and (s[k+1]<>s[i]) do k:=f[k];
        if s[k+1]=s[i] then inc(k);
        f[i]:=k;
      end;
    k:=0;
    for i:=1 to 2*n do
      begin
        while (k>0) and (s[k+1]<>t[i]) do k:=f[k];
        if s[k+1]=t[i] then inc(k);
        if k=n
          then
            begin
              result:=i+n;
              break;
            end;
      end;
    qqq:=result;
  end;

begin
  readln(n);
  for i:=1 to n do read(s[i]);
  readln;
  for i:=1 to n do read(t[i]);
  for i:=1 to n do t[n+i]:=t[i];
  writeln(qqq(s,t,n) mod n);
end.
Re: Why Compilation Error???
Posted by Alias (Alexander Prudaev) 16 Jan 2008 00:05
read FAQ.
Q: I got Compilation Error, how can I learn why my program isn't compiled?
A: If you choose "Reply to this E-Mail address" or "Reply to my E-Mail address" when submitting your solution, then report will be sent to selected e-mail address. In the case of Compilation Error a compilation log will be included in this report. Please, use this feature.