|
|
back to boardWA 11 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 Posted by Solver 21 Jun 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. |
|
|