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

Обсуждение задачи 1158. Censored!

WA 11
Послано IvanShafran 14 окт 2014 20:30
If you use Aho-Korasik+DP you should delete forbidden words which contain other forbidden words.
Example:
alphabet = "01"
forbidden words = ["100", "10", "11"] -> forbidden words = ["10", "11"]
Re: WA 11
Послано Solver 21 июн 2026 21:52
Aho-Corasick has "dictionary" edges for this purpose, so if bad[suffix[i]]==true, then bad[i]=true. Ignoring words that contain other words also works, but it's not true O(N) :) and there is pitfall of some word like "AB" being listed twice and cancelling itself out, so if you go checking for substrings, make sure that the other word is strictly shorter.