#CF808G. Anthem of Berland

Anthem of Berland

Anthem of Berland

  • 时间限制:3 秒
  • 内存限制:512 MiB

题目描述

给定一个由小写英文字母与问号组成的字符串 ss,以及一个仅由小写英文字母组成的字符串 tt

你需要把 ss 中的每个问号替换成任意小写英文字母,使 tt 作为连续子串在最终字符串中出现的次数尽可能多。不同出现可以互相重叠。

请输出能够达到的最大出现次数。

输入格式

第一行包含字符串 ss

第二行包含字符串 tt

输出格式

输出一个整数,表示替换所有问号后 tt 的最大出现次数。

样例输入 1

winlose???winl???w??
win

样例输出 1

5

样例输入 2

glo?yto?e??an?
or

样例输出 2

3

样例输入 3

??c?????
abcab

样例输出 3

2

数据范围

对于所有测试数据,1s,t1000001\le |s|,|t|\le 100\,000st107|s|\cdot |t|\le 10^7ss 仅含小写英文字母与问号,tt 仅含小写英文字母。

子任务编号 分值 特殊限制
1 20 s,t10\lvert s\rvert,\lvert t\rvert\le 10,且问号不超过 33
2 40 s,t18\lvert s\rvert,\lvert t\rvert\le 18
3 无特殊限制

提示

样例 3 的一种最优替换是 abcabcab,其中两次出现互相重叠。