The 7th(2012) ACM Programming Contest of HUST - Onsite Contest(Semilive)
From: 2012-12-16 12:10:00
To: 2012-12-16 17:10:00
Now: 2017-09-20 01:10:41
C - AntiVirus
Time Limit: 5s
Memory Limit: 128MB
Submissions: 401 Solved: 104
- Rocket323 is an engineer(码畜) in an anti-virus software company. One day, he discovered some signatures of a new virus. He wants to know whether his computer is infected with that virus or not?
In this problem, a computer program is a string consists of lowercase English letters. The signature of the new virus is also a string consist of lowercase English letters. The program is infected with the virus if the program consists of at least one signature.
Rocket323 is very curious, so you have to tell him how many signatures appeared in the program.
Because the program is too long, it’s given to you in a compressed format.
- There are multiple test cases. The first line consists of only a integer T (T <= 30) indicating the number of test cases.
For each test case:
The first line contains an integer N (0 < N <= 2000) indicating the number of signatures.
Then n lines follows, each represents a signature of the new virus. It’s guaranteed that the signatures only consist of lowercase English letters and each signature is not empty. The length of each signature is no more than 150 and these N strings are all different.
The last line of each test case is the computer program.
The program will be described in a compressed format. A compressed string consists of lowercase English letters and “compressors”. A “compressor” is in the following format:
q is a number(0 < q <= 10^9) and x is a lowercase English letter. It means q consecutive letter x(s) in the original uncompressed string. For example, [6k] means “kkkkkk” (without the quotes) in the original string. So, if a compressed string is like:
It actually is “abddekkkkkkkg”(without the quotes) after decompressed to original format.
The length of the compressed program is at least 1 and at most 10^6.
The length of the decompressed program is at most 5 * 10^14.
Note that the signature will never be given in the compressed format!
- For each test case:
Print string “Yes”(without the quotes) if the program is infected with the virus, otherwise print “No”(without the quotes), then print the number of signature appeared in the program separated by a space.
Sorry for the trouble caused.
- Sample Input
- Sample Output
- The 7th(2012) ACM Programming Contest of HUST
Problem Setter: Yang Xiao