#P10087. [ROIR 2022] 跳跃机器人 (Day 1)
[ROIR 2022] 跳跃机器人 (Day 1)
Background
Translated from ROIR 2022 D1T2。
A company is developing a jumping robot. To test the robot, they set up a circular route on a polygonal platform, consisting of special platforms numbered from to . The distance between platform and platform is , and the distance between the last platform and the first platform is (assume that edges with lengths can form an -gon)。
The robot is equipped with artificial intelligence and learns to jump farther during testing. At any moment, the robot uses an integer to represent its sensitivity. If is greater than or equal to , the robot can jump from platform to platform ; similarly, if is greater than or equal to , the robot can jump from the last platform to the first platform. After each jump, the robot's sensitivity increases by 。
Problem Description
The robot's developers choose one platform as the starting platform. If the robot can complete jumps and return to the original platform, they consider the experiment successful. The developers need to determine the minimum initial sensitivity of the robot, and which platform to choose as the starting platform。
Input Format
The first line contains an integer 。
The second line contains an integer 。
- If , then the third line contains integers , as described in the Background.
- If , then the third line contains an integer and three integers . The fourth line contains integers . In this case, the distance values are computed by the following formulas:
- If , then 。
- If , then $d_i = ((x \times d_{i−2} + y \times d_{i−1} + z) \bmod 10^9) + 1$。
Output Format
Output two integers: the minimum allowed initial sensitivity and the index of a starting platform where the robot can be placed. If there are multiple starting platforms corresponding to the same minimum initial sensitivity, output any one of them。
5
1
3 7 4 2 5
4 3
10
2
5 1 2 3
1 2 3 4 5
653 1
Hint
Sample explanation:
In the second example, the distance array is 。
Compute the values of to using the formula:
- $d_6 = ((1 \cdot d_4 + 2 \cdot d_5 + 3) \bmod 10^9) + 1 = ((1 \cdot 4 + 2 \cdot 5 + 3) \bmod 10^9) + 1 = 18$;
- $d_7 = ((1 \cdot d_5 + 2 \cdot d_6 + 3) \bmod 10^9) + 1 = ((1 \cdot 5 + 2 \cdot 18 + 3) \bmod 10^9) + 1 = 45$;
- $d_8 = ((1 \cdot d_6 + 2 \cdot d_7 + 3) \bmod 10^9) + 1 = ((1 \cdot 18 + 2 \cdot 45 + 3) \bmod 10^9) + 1 = 112$;
- $d_9 = ((1 \cdot d_7 + 2 \cdot d_8 + 3) \bmod 10^9) + 1 = ((1 \cdot 45 + 2 \cdot 112 + 3) \bmod 10^9) + 1 = 273$;
- $d_{10} = ((1 \cdot d_8 + 2 \cdot d_9 + 3) \bmod 10^9) + 1 = ((1 \cdot 112 + 2 \cdot 273 + 3) \bmod 10^9) + 1 = 662$。
This problem uses bundled testdata。
| Subtask | Points | Special Properties |
|---|---|---|
| and it is guaranteed that starting from the first platform is the best choice | ||
| and it is guaranteed that starting from the first platform is the best choice | ||
For of the data, . When , ; when , , , and 。
Note: the algorithm tags of this problem refer to the methods used in the official solution.
Translated by ChatGPT 5