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 1102. Strange Dialog

Crash???
Posted by Alexander Kouprin 6 Apr 2007 03:13
Please, tell me, why I get access violation??
It's my code:


{$apptype console}
var i,n,x,k,z:integer;
s:ansistring;
a:array[-10000..2000001]of boolean;
t:array[1..6]of string;

function correct(i,j:integer):boolean;
begin
result:=true;
for z:=1 to length(t[j]) do
if s[i+z]<>t[j,z] then begin result:=false; exit; end;
end;

procedure test;
var i,j:integer;
begin
fillchar(a,sizeof(a),false);
a[0]:=true;
for i:=1 to length(s) do
for j:=1 to 6 do
if a[i-length(t[j])] then
if correct(i-length(t[j]),j) then a[i]:=true;
end;

begin
readln(n);
t[1]:='one';
t[2]:='out';
t[3]:='output';
t[4]:='puton';
t[5]:='in';
t[6]:='input';
for i:=1 to n do begin
readln(s);
test;
if a[length(s)] then writeln('YES') else writeln('NO');
end;
end.




I can't understand. Maybe some hint?

Edited by author 06.04.2007 09:56
Re: Crash???
Posted by KIRILL(ArcSTU) 6 Apr 2007 04:17
string can be more 2*10^6 I think..
Re: Crash???
Posted by Alexander Kouprin 6 Apr 2007 09:57
:)
You right.