#CF808G. Anthem of Berland

Anthem of Berland

Anthem of Berland

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

题目描述

给定只含小写英文字母和问号的字符串 ss,以及只含小写英文字母的字符串 tt。把 ss 中的每个问号替换成任意一个小写英文字母,使 tt 在最终字符串 ss 中的出现次数最多。不同出现可以互相重叠。求这个最多出现次数。

输入格式

第一行字符串 ss,第二行字符串 tt。

输出格式

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

样例输入 1

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

样例输出 1

5

样例输入 2

glo?yto?e??an?
or

样例输出 2

3

样例输入 3

??c?????
abcab

样例输出 3

2

数据范围

对于所有测试数据,保证:

  • 1≤∣s∣,∣t∣≤1051\le |s|,|t|\le10^5,∣s∣⋅∣t∣≤107|s|\cdot|t|\le10^7。ss 只含小写英文字母和问号,tt 只含小写英文字母。子任务中的 n,m,qn,m,q 分别表示 ∣s∣,∣t∣|s|,|t| 和 ss 中问号的数量。
测试点编号 分值 特殊限制
1∼61\sim6 22 n,m≤40n,m\le40,q≤3q\le3
7∼127\sim12 44 n≤200n\le200,m≤100m\le100
13∼2013\sim20 33 ss 中没有问号
21∼3021\sim30 44 无