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

Обсуждение задачи 1438. Time Limit Exceeded

OLE on test #4
Послано rkhapov 29 май 2016 18:15
Hi
I have OLE on #4 test
Please, give me some test
P.S. Sorry for my english :(
Re: OLE on test #4
Послано rkhapov 29 май 2016 18:26
i also had tried forward and backward labels, i think my program work correct
Re: OLE on test #4
Послано Jane Soboleva (SumNU) 29 май 2016 22:05
I had OLE #4, and it turned out to be a minor slip in my code. That is, for commands of type «if smth1 <operator> smth2 goto label, i was searching smth1 and smth2 indices in my variable indices array; label i should have searched in my goto indices array, but i accidentally was searching a label index in variable array too; as a result, it returned 0 (which it returned in case if the needed element was the first one, and if the element wasn't found, which shouldn't be happening). So it jumped to the first label and continued from there.

Example:

label1:
A = 10
print 100
label2: goto label2

Due to a mistake, "label2" has been looked for in variables array, which only had "A" in there. It was not found, it returned 0, it jumped to label1, tons of print commands were executed. After mistake is fixed, "label2" is looked for inside labels array, and correctly returns 1.

I can't say for sure you have the very same mistake, but still it is likely just a minor slip like this one.
Re: OLE on test #4
Послано rkhapov 29 май 2016 23:01
I use std::map<std::string, int> for variables and labels.
On your example my program writes:
100
Program terminated. Variables state:
A: 10
I think, its correct. I had tested many similar program and on each of them program's output was correct.
My code: https://gist.github.com/rkhapov/a8dd783fe154813fc2f76649a6f7d9ec