PMT:部分匹配表(Partial Match Table)
表示含义:t[0,i] 的前后缀最大匹配长度
s = input()
t = input()
n,m = len(s),len(t)
pmt = [0] * m
c = 0
for i in range(1,m):
x = t[i]
while c and t[c] != x:
c = pmt[c - 1]
if t[c] == x:
c += 1
pmt[i] = c
c = 0
for i in range(n):
x = s[i]
while c and t[c] != x:
c = pmt[c - 1]
if t[c] == x:
c += 1
if c == m:
print(i - c + 1)
c = pmt[c - 1]
"""
input:
12341234
1234
output:
0
4
"""
标签:pmt,range,len,while,KMP,input
From: https://www.cnblogs.com/gebeng/p/18105748