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

Обсуждение задачи 1350. Столовая

Are there any suffix spaces in input?
Послано Maigo Akisame (maigoakisame@yahoo.com.cn) 9 янв 2006 15:43
My prog gets TLE on test #17. The complexity of my prog is 100*100*log100, so it can't be that it really runs too slow. The only possibility is that it falls into an infinite loop when performing binary search for a food name, because the string inputted contains suffix spaces. Admins please correct this and rejudge the prob if this is true.

Edited by author 10.01.2006 03:41
Re: Are there any suffix spaces in input?
Послано Vladimir Yakovlev (USU) 9 янв 2006 17:37
It can't be solved in  100*100*log100 because input may be as large as 100*100*40. Don't you read the whole input?
Re: Are there any suffix spaces in input?
Послано Maigo Akisame (maigoakisame@yahoo.com.cn) 10 янв 2006 03:41
It doesn't matter. 100*100*log100*40 is about 3e6, which is still not big enough to lead to TLE.
Re: Are there any suffix spaces in input?
Послано Vladimir Yakovlev (USU) 10 янв 2006 04:16
You made a very tricky mistake.
You compare string[40] and string 100*100*log100 times. This comparison works very slow because string[40] is casted to string every time.
Re: Are there any suffix spaces in input?
Послано Maigo Akisame (maigoakisame@yahoo.com.cn) 10 янв 2006 15:00
Thanks. You're right. When I changed 'string' into 'string[40]' I got AC very fast.