8493: Keyboard Warrior

内存限制:128 MB 时间限制:3 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:4 通过:0

题目描述

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 , indicating there are T test cases. In each case:
First line has two integers , indicates the length of your target text, indicates the number of
times you press the key.
Second line has a string of length , which contains only lowercase letters.
For next lines, each line has a character and an integer , their meanings are described above.
    1<= n,m<=2e5
0<=k<=1e9

输出格式

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