CF144C Anagram Search

题目描述

若字符串 $s$ 在交换字母顺序后可以得到 $t$,则称两个串是“相似”的($s$ 为 $t$ 的 anagram)。 给定由小写字母与“?”组成的字符串 $s$ 和由小写字母组成的字符串 $t$。定义一个字符串是好的,当且仅当这个串存在某种将每个“?”替换为一个小写字母的方式,使它与 $p$ 相似(是 $p$ 的 anagram)。问 $s$ 有多少子串是好的(两子串不同当且仅当它们在 $s$ 中的开始位置或终止位置不同)。

输入格式

两行,每行一个字符串,分别为 $s,t$。

输出格式

一行一个整数,代表 $s$ 的好的子串的数量。

说明/提示

Consider the first sample test. Here the string $ s $ has two good substrings: "b??" (after we replace the question marks we get "baa"), "???" (after we replace the question marks we get "baa"). Let's consider the second sample test. Here the string $ s $ has two good substrings: "ab?" ("?" can be replaced by "c"), "b?c" ("?" can be replaced by "a").