#P15588. [KTSC 2026] 飞扬的松鼠 2 / Flying Squirrel 2
[KTSC 2026] 飞扬的松鼠 2 / Flying Squirrel 2
Problem Description
On a 2D plane, there is a flying squirrel and pillars.
We represent a point on the 2D plane as , where the -coordinate represents the offset to the right, and the -coordinate represents the offset upward.
The pillars are numbered in order. The bottom of pillar is at , and its height is infinite. In other words, pillar is a ray starting from and pointing upward. Each pillar is either red or blue. If , pillar is red; otherwise if , pillar is blue.
In the region outside the pillars, the squirrel flies horizontally to the right, keeping its current height unchanged. Since the squirrel is very agile, the time spent flying to the right is considered .
When the squirrel is at a pillar, it can increase its height by , or do nothing. More precisely, at pillar , the squirrel must perform exactly one of the following operations:
- Pass through the pillar. The squirrel’s height does not change, and it continues flying to the right. The time cost is .
- Climb up the pillar. This operation can be performed if and only if the pillar is red (). The squirrel’s height increases by , then it continues flying to the right. The time cost is .
- Jump up the pillar. This operation can be performed if and only if the pillar is blue (). The squirrel’s height increases by , then it continues flying to the right. The time cost is .
In addition, when the squirrel’s -coordinate is (), its height must be within . When the squirrel’s -coordinate is , its height must be .
Let be the minimum time needed for the squirrel to reach while satisfying all the conditions above and using exactly “Jump up” operations. If no such plan exists, let .
Compute .
Implementation Details
This is a functional interactive problem. You do not need to, and should not, implement the main function.
You should implement the following function:
vector<long long> fly(int H, vector<int> A, vector<int> B, vector<int> L, vector<int> R)
- : the squirrel’s final height.
- : integer arrays of length .
- : the array describing pillar colors. If , pillar is red; otherwise if , pillar is blue.
- This function must return an array of length .
- This function is called exactly once.
Your source code should not call any input/output functions.
Input Format
The input format of the sample grader is as follows:
- Line :
- Line :
- Line :
- Line :
- Line :
Output Format
The sample grader prints the answer in the following format:
- Line :
4 3
8 8 2 4
1 0 1 0
1 0 2 3
1 2 2 4
-1 20 14 -1
1 1
1000000000
0
1
1
1000000000 -1
7 3
4 7 0 3 8 4 5
0 0 0 0 0 0 0
0 0 0 1 0 1 2
5 1 2 5 5 6 3
7 -1 -1 -1
20 7
3 3 4 1 3 2 0 1 4 3 4 0 0 1 0 4 4 5 5 0
1 1 0 0 1 1 0 1 0 0 0 0 0 0 1 1 1 0 0 1
0 0 1 1 2 1 2 2 1 1 0 1 1 3 2 2 1 6 4 4
3 2 3 3 6 2 2 4 3 4 4 5 3 6 6 5 7 8 8 9
-1 16 11 10 9 10 12 15
Hint
Constraints
- ;
- ;
- ;
- ;
- 。
Subtasks
| ID | Score | Constraint |
|---|---|---|
| No additional constraints. |
Samples
Sample
Consider the following call.
fly(3, [8, 8, 2, 4],
[1, 0, 1, 0],
[1, 0, 2, 3],
[1, 2, 2, 4])
::::align{center}
::::
If the squirrel jumps up pillar and climbs up pillars and , then the conditions are satisfied. In this case, the number of “Jump up” operations is , and the time cost is seconds.
::::align{center}
::::
If the squirrel jumps up pillars and and climbs up pillar , then the conditions are satisfied. In this case, the number of “Jump up” operations is , and the time cost is seconds.
There are no other possible ways. Therefore, the function should return [, , , ].
Sample
Consider the following call.
fly(1, [1000000000],
[0],
[1],
[1])
The function should return .
Sample
Consider the following call.
fly(3, [4, 7, 0, 3, 8, 4, 5],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 1, 2],
[5, 1, 2, 5, 5, 6, 3])
The function should return .
Sample
Consider the following call.
fly(7, [3, 3, 4, 1, 3, 2, 0, 1, 4, 3, 4, 0, 0, 1, 0, 4, 4, 5, 5, 0],
[1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1],
[0, 0, 1, 1, 2, 1, 2, 2, 1, 1, 0, 1, 1, 3, 2, 2, 1, 6, 4, 4],
[3, 2, 3, 3, 6, 2, 2, 4, 3, 4, 4, 5, 3, 6, 6, 5, 7, 8, 8, 9])
The function should return 。
Translated by ChatGPT 5