Topic 9: String: Hash, KMP, AC Automata
CS 311 - Competitive Programming II (Fall 2023)
Zhongtang Luo (Instructor)
Code Presentation
Problem… (Subsequences in Substrings)
NAIPC 2019
Not all problems need a technique…
Sample: s=aaaaa, t=aaa
String Search
String Search: Rolling Hash
String Search: Rolling Hash
Problem… (Palindromes)
There are very famous algorithms that deal with palindromes (Manacher, palindrome tree, etc.)
But for this problem, try to solve it with hash + BSTA.
String Match: Trie?
Problem… (Remember the Word)
String Search: Automata
String Search: KMP
String Search: AC Automata
Problem… (Anthem of Berland)
Hint: let dp[i][j] be the case that we are at i-th position in the string and at the j-th position in KMP.
Problem… (DNA repair)