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

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

What a strange problem(+)
Послано Safe Bird 25 фев 2006 18:59
i suppose simulation will cause timeout since there exist "divide" operations.

any idea? :(
Re: What a strange problem(+)
Послано Rostislav 25 фев 2006 19:11
I think, if you preproccess the program at the begining and parse it in a more suitable way simulation may work. I haven't written it that way yet, so it is possible to be wrong.

 Rostislav
Re: What a strange problem(+)
Послано Denis Nazarov 25 фев 2006 19:26
My program works about 0.6 secs to perform 10.000.000 iterations. But I cann't check its correctness due errors in judge data.
program written out now, but (+)
Послано Safe Bird 25 фев 2006 21:07
how do the "/" and "%" work while processing with negative numbers?...

and how about "not" operator? (i am not very sure what complement code is, sorry)
Re: program written out now, but (+)
Послано Aleksandr Klepinin 25 фев 2006 22:48
Complement code = two's complement representation (I'm sorry for wrong translation of this term from Russian). Problem text is updated.

Simulation must be very efficient for this problem get accepted. Approach of Denis Nazarov is quite correct.
..faint, see in(+)
Послано Safe Bird 26 фев 2006 16:45
Complement code is more accurate i think. but i don't know what Complement code is... i hope you can explain it.
directly use "~int" in c++?


and, you still haven't modified from 10^8 to 10^8 + 1...


what is more, how do "/" and "%" work? could you give us some examples?????
Re: ..faint, see in(+)
Послано Ivankov Dmitry 26 фев 2006 19:08
not: ~int
/: int/int
"a % b": minimal non-negative r such that (a - r) % b == 0
and(+)
Послано Safe Bird 26 фев 2006 22:20
/:   int/int? then we have:

-6 % -5 = 4,
but
-6 / -5 = 1?(but not 2?)

thanx
Re: and(+)
Послано Aleksandr Klepinin 27 фев 2006 01:16
I will not change 10^8 to 10^8 + 1 because it is easier to fix the error in my own solution and update tests (it is done already).

Moreover, I updated the second sample. Now it clarifies how remainder is calculated. Yes, as Dmitry already noted remainder is calculated in mathematical sense. I made it intentionally for the programmers to pay attention to how it works with negative numbers. It is a well known fact, that in most programming languages remainder is not calculated properly in mathematical sense (by definition, remainder is never negative, but in programming languages it sometimes is negative).
Re: ..faint, see in(+)
Послано Aleksandr Klepinin 27 фев 2006 01:22
Concerning the terms.
As I found, "two's complement representation" is a correct English term for what is known in Russian as a "complement code". There is also "one's complement representation". Just search with Google for this terms and you find the definitions for them.

For example, look here: http://en.wikipedia.org/wiki/Two's_complement
Re: ..faint, see in(+)
Послано LSD Crew 3 мар 2006 15:23
This definition must include in the problem text, because
usual math definition is (see wikipedia)

a mod b=a-b*floor(a/b)
5 mod -2 = 5 -(-2)*floor(-5/2)= 5 - (-2) *(-3)=5-6= -1

In programming languages the result 5%(-2) is 1.

But -5 mod 2 is 1, and (-5)%2 is -1

Edited by author 03.03.2006 15:28
Re: and(+)
Послано Igor E. Tuphanov 3 мар 2006 17:25
Who passed test #7? Is it so tricky? Maybe, it's smth with lower/upper cases there.
As I understood:
- labels - do not care about case (loop == Loop)
- commands - also do no care (iF = If)
- vearables - care
Re: and(+)
Послано Igor E. Tuphanov 3 мар 2006 17:38
Yeah, and what about test, where "end" is 10^8 command?
i remember 10^8 and 10^8+1 will both pass cases 1..11. (+)
Послано Safe Bird 3 мар 2006 17:46
maybe 10^8+1 will also get AC, i donno exactly.
Re: ..faint, see in(+)
Послано svr 28 янв 2009 21:45
What for we are enabled information
about 2-complement?
In programm we work with 10-basis
where '-' presence.
Going far:
Spaces may be anywhere…
And in string + 5  78 999 ?
I have WA9 and suspect trics.

I found in test 9 situation:
in some row string consist of one
persistent block without spaces
and doesn't contain':'

Acording decription it must be "end" but
it is another word.
What is may be!?


AC at last.
Admins! You are not all right!
In test 9 <commands> may be continued on the next row!
In other words we have flow of words but
in problem decription we see flow of rows.
I lost 1 day before rewritten grammar analizer
in terms of flow of words.

Edited by author 30.01.2009 20:16
Re: ..faint, see in(+)
Послано Vedernikoff Sergey (HSE: EconomicsForever!) 2 фев 2009 11:27
I got AC assuming all is OK. And all is really OK, since in case of "flow of words" you write about my program should have failed. So, debug your program - problem is not in tests...
Re: ..faint, see in(+)
Послано svr 2 фев 2009 13:29
I used getline firstly and WA9 during a long time.
After I made program with cin>> and got Ac quickly.
Now I have absolute surely that much is more easy to get
AC taking information word by word or from" flow of words".