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

Обсуждение задачи 1769. Старая уральская легенда

finally
Послано Anton 27 янв 2012 12:28
I'm laughing now ....
I've spent about 3 hours for this problem.
First off, I used Z-function and I tried to treat problem as a string problem. I generated new string and tried to find it. If there is no, that's the answer.
It became not so slow as can seems to be. But TLE#6 got me!
Then I tried to store positions for each digit(0-9) and than tried to search target number using binary search for every digit. It works, but not good enough to pass test#6.
Then I decided to use the straight approach using bool exists[1000000] that indicates whether n is substring. It approach can be done since total length is 10^5, so 10^6 is free for sure.

Since we know several approaches sometimes we use more complex first :)
Re: finally
Послано inatial_D 2 апр 2013 19:42
cool.
Re: finally
Послано Амир Меннибаев 21 мар 2017 23:04
good idea!