#P7099. [yLOI2020] 灼
[yLOI2020] 灼
Description
This is NS05. There is no sign of life left on the Leiben planet. Requesting rescue! Puer! Can you hear me? I will stay here and wait for your return.
Fusu is trapped on the Leiben planet. Zhuo Wenyu is piloting a spaceship and plans to travel through a wormhole to reach Leiben and rescue Fusu.
On a number line, there are wormholes. The coordinate of the -th wormhole is . Entering any one of these wormholes can directly take you to Leiben and rescue Fusu. After the spaceship reaches the straight line containing the number line, it will lose control due to the magnetic field. Each second, it will move one unit to the left or to the right with equal probability.
Zhuo Wenyu is very anxious. He gives initial coordinates where the spaceship enters the line of the number line. For each coordinate, he wants to know the expected number of seconds needed to reach a wormhole.
If the expected value you compute is a fraction, you need to output the value modulo . For the definition of taking a fraction modulo a prime, you can refer to the content in “Hint”.
To avoid the output being too large, you only need to output four integers: the bitwise XOR of all answers (after taking modulo , same below), how many of your answers are odd, the maximum among all your answers, and the minimum among all your answers.
Input Format
The first line contains an integer , which is the index number corresponding to the test point.
The second line contains two integers, representing the number of wormholes and the number of initial coordinates .
The third line contains integers. The -th integer represents the coordinate of the -th wormhole .
The next lines each contain one integer, representing an initial coordinate where the spaceship enters the line of the number line.
It is guaranteed that are given in non-decreasing order.
Output Format
Output four lines, each containing one integer, in order: the bitwise XOR of all answers, how many answers are odd, the maximum answer, and the minimum answer.
0
2 3
1 3
1
2
3
1
1
1
0
Hint
Sample 1 Explanation
There are wormholes at points and on the number line. When the initial coordinate is or , the spaceship can enter a wormhole immediately and costs . When the initial coordinate is , there is a probability of to move one unit to the left, costing to enter a wormhole, and also a probability of to move one unit to the right, costing to enter a wormhole. The expected time is .
Therefore, the answers to the three queries are .
Constraints and Conventions
This problem has test points, and each test point is worth points.
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that for any wormhole, there always exists another wormhole such that the distance between them is at most . For example, in the sample, the distance between the two wormholes is .
- For of the testdata, it is guaranteed that for any wormhole, there always exists another wormhole such that the distance between them is at most .
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that , , . Also, is not less than the minimum of , and is not greater than the maximum of . The values are given in non-decreasing order.
Hint
-
If you do not know what it means to take a fraction modulo a prime, you can refer to the following:
For an irreducible fraction of the form , where , its value modulo is .
-
To make it easier to generate data by hand, the data does not guarantee that all are distinct.
-
Please note that reading a large amount of data may affect the efficiency of your program.
-
This special output format is only to avoid TLE due to overly large output, and it is unrelated to the solution of this problem.
-
Please note that is not the number of test cases.
-
This problem has two additional files; see zhuo.zip in the attachment files.
Translated by ChatGPT 5
京公网安备 11011102002149号