A9772 | Tavas and Malekas
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string $s$ of length $n$ comes out from Tavas' mouth instead.
Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on $s$ . Malekas has a favorite string $p$ . He determined all positions $x_{1}<x_{2}<...<x_{k}$ where $p$ matches $s$ . More formally, for each $x_{i}$ ( $1<=i<=k$ ) he condition $s_{xi}s_{xi}+1...\ s_{xi}+|p|-1=p$ is fullfilled.
Then Malekas wrote down one of subsequences of $x_{1},x_{2},...\ x_{k}$ (possibly, he didn't write anything) on a piece of paper. Here a sequence $b$ is a subsequence of sequence $a$ if and only if we can turn $a$ into $b$ by removing some of its elements (maybe no one of them or all).
After Tavas woke up, Malekas told him everything. He couldn't remember string $s$ , but he knew that both $p$ and $s$ only contains lowercase English letters and also he had the subsequence he had written on that piece of paper.
Tavas wonders, what is the number of possible values of $s$ ? He asked SaDDas, but he wasn't smart enough to solve this. So, Tavas asked you to calculate this number for him.
Answer can be very large, so Tavas wants you to print the answer modulo $10^{9}+7$ .
Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on $s$ . Malekas has a favorite string $p$ . He determined all positions $x_{1}<x_{2}<...<x_{k}$ where $p$ matches $s$ . More formally, for each $x_{i}$ ( $1<=i<=k$ ) he condition $s_{xi}s_{xi}+1...\ s_{xi}+|p|-1=p$ is fullfilled.
Then Malekas wrote down one of subsequences of $x_{1},x_{2},...\ x_{k}$ (possibly, he didn't write anything) on a piece of paper. Here a sequence $b$ is a subsequence of sequence $a$ if and only if we can turn $a$ into $b$ by removing some of its elements (maybe no one of them or all).
After Tavas woke up, Malekas told him everything. He couldn't remember string $s$ , but he knew that both $p$ and $s$ only contains lowercase English letters and also he had the subsequence he had written on that piece of paper.
Tavas wonders, what is the number of possible values of $s$ ? He asked SaDDas, but he wasn't smart enough to solve this. So, Tavas asked you to calculate this number for him.
Answer can be very large, so Tavas wants you to print the answer modulo $10^{9}+7$ .
输入格式
The first line contains two integers $n$ and $m$ , the length of $s$ and the length of the subsequence Malekas wrote down ( $1<=n<=10^{6}$ and $0<=m<=n-|p|+1$ ).
The second line contains string $p$ ( $1<=|p|<=n$ ).
The next line contains $m$ space separated integers $y_{1},y_{2},...,y_{m}$ , Malekas' subsequence ( $1<=y_{1}<y_{2}<...<y_{m}<=n-|p|+1$ ).
The second line contains string $p$ ( $1<=|p|<=n$ ).
The next line contains $m$ space separated integers $y_{1},y_{2},...,y_{m}$ , Malekas' subsequence ( $1<=y_{1}<y_{2}<...<y_{m}<=n-|p|+1$ ).
输出格式
In a single line print the answer modulo $1000000007$ .
输入输出样例
输入 #1
6 2 ioi 1 3
输出 #1
26
输入 #2
5 2 ioi 1 2
输出 #2
0
In the first sample test all strings of form "ioioi?" where the question mark replaces arbitrary English letter satisfy.
Here $|x|$ denotes the length of string x.
Please note that it's possible that there is no such string (answer is 0).
Here $|x|$ denotes the length of string x.
Please note that it's possible that there is no such string (answer is 0).
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted