1. 程式人生 > >codeforces 808G Anthem of Berland

codeforces 808G Anthem of Berland

pos lin -m body def 參考 博客 後綴 post

codeforces 808G Anthem of Berland

題面

給定\(s\)串和\(t\)串,字符集是小寫字母。\(s\)串中有些位置的值不確定,要求你確定這些位置上的值,使得\(t\)\(s\)中出現次數最多,輸出最多出現次數。

參考博客

http://www.cnblogs.com/Oncle-Ha/p/7061929.html

題解

AC自動機預處理 \(ne[i][j]\):字符串 \(t[i]+j\) 的後綴最長匹配到 \(t[ne[i][j]]\)
狀態\(f[i][j]\)\(s[i]\)的後綴最長匹配到\(t[j]\),並且\(s[i]\)完美匹配\(t\)\(f[i][j]\)

次。

codeforces 808G Anthem of Berland