A10608 | Games on a CD
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Several years ago Tolya had $n$ computer games and at some point of time he decided to burn them to CD. After that he wrote down the names of the games one after another in a circle on the CD in clockwise order. The names were distinct, the length of each name was equal to $k$ . The names didn't overlap.
Thus, there is a cyclic string of length $n·k$ written on the CD.
Several years have passed and now Tolya can't remember which games he burned to his CD. He knows that there were $g$ popular games that days. All of the games he burned were among these $g$ games, and no game was burned more than once.
You have to restore any valid list of games Tolya could burn to the CD several years ago.
Thus, there is a cyclic string of length $n·k$ written on the CD.
Several years have passed and now Tolya can't remember which games he burned to his CD. He knows that there were $g$ popular games that days. All of the games he burned were among these $g$ games, and no game was burned more than once.
You have to restore any valid list of games Tolya could burn to the CD several years ago.
输入格式
The first line of the input contains two positive integers $n$ and $k$ ( $1<=n<=10^{5}$ , $1<=k<=10^{5}$ ) — the amount of games Tolya burned to the CD, and the length of each of the names.
The second line of the input contains one string consisting of lowercase English letters — the string Tolya wrote on the CD, split in arbitrary place. The length of the string is $n·k$ . It is guaranteed that the length is not greater than $10^{6}$ .
The third line of the input contains one positive integer $g$ ( $n<=g<=10^{5}$ ) — the amount of popular games that could be written on the CD. It is guaranteed that the total length of names of all popular games is not greater than $2·10^{6}$ .
Each of the next $g$ lines contains a single string — the name of some popular game. Each name consists of lowercase English letters and has length $k$ . It is guaranteed that the names are distinct.
The second line of the input contains one string consisting of lowercase English letters — the string Tolya wrote on the CD, split in arbitrary place. The length of the string is $n·k$ . It is guaranteed that the length is not greater than $10^{6}$ .
The third line of the input contains one positive integer $g$ ( $n<=g<=10^{5}$ ) — the amount of popular games that could be written on the CD. It is guaranteed that the total length of names of all popular games is not greater than $2·10^{6}$ .
Each of the next $g$ lines contains a single string — the name of some popular game. Each name consists of lowercase English letters and has length $k$ . It is guaranteed that the names are distinct.
输出格式
If there is no answer, print "NO" (without quotes).
Otherwise, print two lines. In the first line print "YES" (without quotes). In the second line, print $n$ integers — the games which names were written on the CD. You should print games in the order they could have been written on the CD, it means, in clockwise order. You can print games starting from any position. Remember, that no game was burned to the CD more than once. If there are several possible answers, print any of them.
Otherwise, print two lines. In the first line print "YES" (without quotes). In the second line, print $n$ integers — the games which names were written on the CD. You should print games in the order they could have been written on the CD, it means, in clockwise order. You can print games starting from any position. Remember, that no game was burned to the CD more than once. If there are several possible answers, print any of them.
输入输出样例
输入 #1
3 1 abc 4 b a c d
输出 #1
YES 2 1 3
输入 #2
4 2 aabbccdd 4 dd ab bc cd
输出 #2
NO
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted