CF808G.Anthem of Berland
提高+/省选-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Berland has a long and glorious history. To increase awareness about it among younger citizens, King of Berland decided to compose an anthem.
Though there are lots and lots of victories in history of Berland, there is the one that stand out the most. King wants to mention it in the anthem as many times as possible.
He has already composed major part of the anthem and now just needs to fill in some letters. King asked you to help him with this work.
The anthem is the string s of no more than 105 small Latin letters and question marks. The most glorious victory is the string t of no more than 105 small Latin letters. You should replace all the question marks with small Latin letters in such a way that the number of occurrences of string t in string s is maximal.
Note that the occurrences of string t in s can overlap. Check the third example for clarification.
伯兰德拥有悠久而辉煌的历史。为了向年轻公民普及这段历史,伯兰德国王决定创作一首国歌。
尽管伯兰德历史上取得了无数胜利,但其中有一场最为突出。国王希望在国歌中尽可能多地提及这场最辉煌的胜利。
他已完成了国歌的主要部分,目前只需填入一些字母。国王请你协助完成这项工作。
国歌是一个字符串 s,长度不超过 105,由小写拉丁字母和问号(?)组成;那场最辉煌的胜利则对应一个字符串 t,长度不超过 105,仅由小写拉丁字母组成。你需要将字符串 s 中所有问号替换为小写拉丁字母,使得字符串 t 在 s 中的出现次数最大化。
注意:字符串 t 在 s 中的出现可以重叠。请参考第三个样例以进一步理解。
输入格式
The first line contains string of small Latin letters and question marks s (1 ≤ |s| ≤ 105).
The second line contains string of small Latin letters t (1 ≤ |t| ≤ 105).
Product of lengths of strings |s|·|t| won't exceed 107.
第一行包含一个由小写拉丁字母和问号组成的字符串 s(1 ≤ ∣s∣ ≤ 105)。
第二行包含一个由小写拉丁字母组成的字符串 t(1 ≤ ∣t∣ ≤ 105)。
字符串长度的乘积 ∣s∣⋅∣t∣ 不超过 107。
输出格式
Output the maximum number of occurrences of string t you can achieve by replacing all the question marks in string s with small Latin letters.
输出通过将字符串 s 中的所有问号替换为小写拉丁字母,所能达到的字符串 t 出现次数的最大值。
输入输出样例
输入#1
winlose???winl???w?? win
输出#1
5
输入#2
glo?yto?e??an? or
输出#2
3
输入#3
??c????? abcab
输出#3
2
说明/提示
In the first example the resulting string s is "winlosewinwinlwinwin"
In the second example the resulting string s is "glorytoreorand". The last letter of the string can be arbitrary.
In the third example occurrences of string t are overlapping. String s with maximal number of occurrences of t is "abcabcab".
在第一个例子中,得到的字符串 s 为 "winlosewinwinlwinwin"。
在第二个例子中,得到的字符串 s 为 "glorytoreorand"。字符串的最后一个字母可以是任意字符。
在第三个例子中,字符串 t 的出现位置存在重叠。使得 t 出现次数最多的字符串 s 是 "abcabcab"。
输入解题思路,AI测评打分。不知道怎么写?