「一本通 2.3 练习 3」Secret Message 秘密信息
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Description
Original source: USACO 2008 Dec. Gold
Bessie is leading the cows in an escape. To communicate, the cows send secret messages to each other.
The messages are binary and consist of entries. John, who has strong anti-spying capabilities, has partially intercepted these messages and knows the first bits of the -th binary message. He also knows that the cows use passwords. However, he only knows the first bits of the -th password.
For each password , he wants to know how many intercepted messages can match it. That is, how many messages share the same prefix with this password. Of course, the length of this prefix must be equal to the smaller of the password length and the message length.
Input Format
The first line contains and , followed by lines describing the secret messages and then lines describing the passwords. Each line starts with an integer indicating the length of the message or password, followed by the message or password itself.
All numbers are separated by spaces.
Output Format
Output lines, each indicating the number of matching messages for the corresponding password.
Sample 1
messages and passwords.
The intercepted message prefixes are , and the possible password prefixes are .
only matches ;
matches ;
only matches ;
matches ;
matches .
4 5
3 0 1 0
1 1
3 1 0 0
3 1 1 0
1 0
1 1
2 0 1
5 0 1 0 0 1
2 1 1
1
3
1
1
2
Data Range and Hints
For of the data, $1\le M\le 50000,1\le N\le 50000,1\le b_i\le 10000,1\le c_j\le 10000$. The total number of bits, i.e., , does not exceed .
20251130 D班作业(8)
- Status
- Done
- Problem
- 4
- Open Since
- 2025-11-30 0:00
- Deadline
- 2025-12-15 23:59
- Extension
- 24 hour(s)