#P4424. [HNOI/AHOI2018] 寻宝游戏
[HNOI/AHOI2018] 寻宝游戏
Description
At a certain university, there is an annual Mystery Hunt. Players must solve puzzles using given clues to find the treasure, and the previous year's winning team earns the right to write the problems for the current year.
As a freshman, you are very interested in this event. Every day you walk from west to east through a very long corridor in the teaching building. The corridor is so long that people jokingly call it the "infinite corridor." One day, as you pass through the corridor, you notice that there are hidden binary numbers of equal length on the corridor wall, all of length . You record these numbers from west to east, forming a binary array of numbers .
Soon, in the latest issue of the Voo Doo magazine, you discover binary numbers of length , namely .
You quickly figure out the meaning of these numbers.
Keeping the order of the array unchanged, you may insert (bitwise AND) or (bitwise OR) between them. For example: , .
You need to insert operators: exactly one between each pair of adjacent numbers, and one more to the left of the first number. If we put a to the left of the first operator, this forms an expression whose value we can compute. As usual, the evaluation order is from left to right. Interestingly, the setter has already told you the possible set of resulting values — the binary numbers in the Voo Doo magazine. The way to solve the puzzle is: for each value among , compute how many ways there are to fill in these operators so that the expression evaluates to .
However, the infinite corridor is truly long, which means the ranges may be very large. Therefore, the answers may also be very large, but due to the special nature of the puzzle, you only need to output the answers modulo .
Input Format
The first line contains three integers , as described.
The next lines: the -th line contains a binary number of length , with the most significant bit on the left, representing .
The next lines: the -th line contains a binary number of length , with the most significant bit on the left, representing .
Output Format
Output lines, one integer per line. The -th line is the answer for .
5 5 1
01110
11011
10000
01010
00100
00100
6
10 10 3
0100011011
0110100101
1100010100
0111000110
1100011110
0001110100
0001101110
0110100001
1110001010
0010011101
0110011111
1101001010
0010001001
69
0
5
Hint
Constraints:
- For of the testdata, , , .
- For an additional of the testdata, , .
- For an additional of the testdata, , .
- For all testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号