#P11066. 【MX-X4-T6】「Jason-1」电梯
【MX-X4-T6】「Jason-1」电梯
Background
Original link: https://oier.team/problems/X4G.
Problem Description
A building with floors has elevators. Each elevator can be in two states: stationary or moving.
Initially, elevator is stationary on floor . Given a permutation of , you want elevator to end up on floor .
You can perform the following two types of operations:
0: Move time forward by one moment.x: where is a positive integer not exceeding .- To perform this operation, the following must hold: there is no stationary elevator on floor ; the stationary elevator that is closest to floor exists and is unique.
- Let be the index of the nearest stationary elevator, and be its position. Then elevator immediately becomes a moving elevator, and it will arrive at floor and become stationary before all operations after moments.
: The distance between an elevator located on floor and floor is .
Note: You must ensure that at any time, there are not two stationary elevators on the same floor.
For each testdata, there is a scoring parameter . You must construct a plan whose total number of operations does not exceed in order to pass that testdata.
This problem uses a custom checker to verify whether your answer is correct. Therefore, if there are multiple valid plans, you only need to output any one.
Input Format
This problem input contains multiple test cases.
The first line contains a positive integer , the number of test cases. For each test case:
- The first line contains four positive integers , representing the number of queries, the number of floors, the number of elevators, and the scoring parameter.
- The next lines each contain integers , representing the target positions of the elevators.
Output Format
For each test case:
- Output a total of lines. For each query, output two lines:
- The first line contains a non-negative integer , the number of operations in your plan.
- The second line contains integers in , representing your specific sequence of operations.
This problem uses a custom checker to verify whether your answer is correct. Therefore, if there are multiple valid plans, you only need to output any one.
2
2 4 2 12
1 2
2 1
1 10 5 30
5 4 3 2 1
0
9
3 4 0 0 1 0 2 0 0
16
6 6 6 6 6 0 1 0 2 0 3 0 4 0 5 0
1
1 6 5 30
5 4 3 2 1
16
6 6 6 6 6 0 1 0 2 0 3 0 4 0 5 0
Hint
[Sample Explanation #1]
This sample satisfies the constraints of Subtask 2.
For the first query of the first test case, no operation is needed.
For the second query of the first test case:
| Operation | Time | Elevator Position | Elevator Position |
|---|---|---|---|
| Initial state | |||
| moving | |||
| moving | |||
| moving | |||
| moving | |||
[Sample Explanation #2]
This sample satisfies the constraints of Subtask 7.
[Constraints]
This problem uses bundled test.
| Subtask | Score | |||
|---|---|---|---|---|
| 1 | ||||
| 2 | ||||
| 3 | ||||
| 4 | ||||
| 5 | ||||
| 6 | ||||
| 7 | ||||
For all testdata, , . It is guaranteed that simultaneously satisfy the constraints of some subtask above. is a permutation of . , .
Translated by ChatGPT 5