当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7157:Keyboard Warrior

题目描述
Some contestants said on the Internet that they love Multi-University Training, did the rest of them have no keyboards?

You must be the one whose keyboard is badly broken. When you press a key, it triggers a random number of times.

Given a character $ch$ and an integer $k$, it means you press an alphanumeric key $ch$ only once, but it triggers $k$ times, and $k$ character $ch$ will be added to the end of the buffer.

Given a character '-' and an integer $k$, it means you press the backspace key, it triggers $k$ times, delete $k$ characters from the end (If the number of characters is less than $k$, the buffer will be cleared).

Given the operations in chronological order, could you input your target text? Which means whether there is a time, your target text is a substring of your buffer characters? Answer 'yes' or 'no'. (In formal language theory and computer science, a substring is a contiguous sequence of characters within a string.)
输入解释
First line has one integer $T$, indicating there are $T$ test cases. In each case:

First line has two integers $n, m$, $n$ indicates the length of your target text, $m$ indicates the number of times you press the key.

Second line has a string of length $n$, which contains only lowercase letters.

For next $m$ lines, each line has a character $ch$ and an integer $k$, their meanings are described above.

$1 \leq n, m \leq 2 \times 10^5, 0 \leq k \leq 10^9, \sum {(n+m)} \leq 2\times 10^6$
输出解释
In each case, print 'yes' or 'no', without quote.
输入样例
3
6 6
iloveu
i 1
l 1
o 1
v 1
e 1
u 0
6 10
imfive
u 10
- 20
i 1
m 1
f 1
i 1
v 5
- 4
e 2
- 2
4 4
abab
a 2
b 2
- 3
b 1
输出样例
no
yes
no

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7157

最后修改于 2022-09-15T06:17:05+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 524288/524288K(Java/Others)