#P5688. [CSP-S 2019 江西] 散步
[CSP-S 2019 江西] 散步
Description
There are people taking a walk in a park. As it gets late, everyone is ready to go home and leave the park. The park is a circular graph (a ring) with exits. For convenience, we number the people from to , and number the exits from to in counterclockwise order.
The total length of the park is meters. We define the position of exit as meters. Then for exit , it is located meters counterclockwise from exit . The sequence is strictly increasing, so exits and are adjacent. Since the park is a ring, exit and exit are also adjacent. Each exit also has a capacity limit , meaning that at most people can leave through exit .
When going home, each person will keep moving in their own direction, either clockwise or counterclockwise. When they reach an exit that still allows someone to leave, they will leave the park through that exit. In particular, if two people arrive at an exit that can allow only person to leave at the same time, the person with the smaller index leaves through that exit, and the person with the larger index continues moving.
Now you are given the initial position and moving direction of each of the people. Please determine which exit each person leaves from. If person leaves from exit , you only need to output the XOR sum of , that is:
$$(1\times k_1) \operatorname{xor} (2\times k_2) \operatorname{xor}\cdots \operatorname{xor} (n\times k_n)$$where is the bitwise XOR operation. In particular, if a person cannot leave in the end, then .
Input Format
The first line contains three positive integers , as described above.
The second line contains positive integers , representing the exit positions. It is guaranteed that is strictly increasing.
The third line contains positive integers , representing the capacity limit of each exit.
The next lines each contain two integers . If is , it means person moves counterclockwise; if is , it means person moves clockwise. means the starting position of person is the point meters counterclockwise from exit .
Output Format
Output one integer in a single line, representing the answer.
3 2 5
2
2 1
0 1
1 3
0 4
3
3 2 5
2
1 1
0 0
0 2
0 1
5
Hint
Explanation of Sample 1
People leave through exits , respectively.
Explanation of Sample 2
People leave through exits , respectively, and person cannot leave the park.
Constraints
For of the testdata: .
For of the testdata: , .
For of the testdata: .
For another of the testdata: , and all .
For of the testdata: , , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号