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 1098. Questions

ML4 !( HOW can it be?(
Posted by Sergey Baskakov, Raphail and Denis 10 Apr 2005 16:05
I'm continuously getting Memory Limit Exceeded on test #4...
IMHO, the problem can only be in the following lines (when I input the question):


var question: string;
....ch: char;
begin

..question := '';
..while not eof do
..begin
....Read( ch );
....if ( ch <> #10 ) and ( ch <> #13 ) then Insert(ch,question,Length(question)+1);
..end;

..// here comes some more code...

end.


If you think the problem can be hidden somewhere else in my code, I'll provide the whole listing.

Thank you in advance!

rafailka.

Edited by author 10.04.2005 16:32
Yeah!) Now I know, HOW it can be!!! I got AC!!!
Posted by Sergey Baskakov, Raphail and Denis 10 Apr 2005 16:32
After having received MLE for 10 times, I finally figured out the following input method:


var question: array [1..30000] of char;
....questionLen: smallint;

....procedure ReadThatDisgustingQuestion;
....var ch: char;
....begin

......questionLen := 0;
......while not eof do
......begin
........Read( ch );
........if ( ch <> #10 ) and ( ch <> #13 ) then
........begin
..........inc( questionLen );
..........question[ questionLen ] := ch;
........end;
......end;

....end;


Online Status says, that this solution requires 124 K - right what I was expecting to see (^:

But why did I get MLE (more than 1Mb of memory), when using common strings? I still don't understand... Are there any tricks in fpc implementation of HUGE strings?

rafailka.