ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1098. Questions

ML4 !( HOW can it be?(
Послано Sergey Baskakov, Raphail and Denis 10 апр 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!!!
Послано Sergey Baskakov, Raphail and Denis 10 апр 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.