#P17274. [eJOI 2026] Elevator
[eJOI 2026] Elevator
Problem Description
This is a communication problem.
There is a building with floors numbered from to . Floor is the ground floor, and above floor is the rooftop. Thus, including the rooftop, the building has levels.
Each floor with is occupied by exactly one resident and has a secret integer with , known only to that resident. Karlsson lives on the rooftop. His objective is to determine as many values among as possible, while every resident cooperates to maximize the number of values he can recover.
The residents communicate using the building's elevator as follows.
The elevator starts on floor and travels only upward. It has buttons labelled through . Initially no buttons are pressed; once pressed, a button remains pressed permanently. The elevator stops and opens on floor if either or the button for floor was pressed at an earlier stop. After visiting the highest floor whose button has been pressed, or floor if no button is ever pressed, the elevator goes directly to the rooftop without stopping at any remaining floors.
When the elevator stops on floor :
- The resident sees the complete set of buttons currently pressed.
- Based only on this information and on , the resident may press any subset of the currently unpressed buttons for floors strictly above .
- The elevator moves to the lowest higher floor whose button is pressed, or to the rooftop if every floor with a pressed button has already been visited.
If the elevator does not stop at a floor, that floor's resident cannot press any buttons.
At the rooftop, Karlsson sees only the final set of pressed buttons. From this information, he tries to recover as many of as possible.
The values of are fixed before your program starts and do not change during the process.
Implementation details
There are test cases. Submit one file implementing the following two functions.
std::vector<int> press_buttons(int subtask, int N,
int f, int v, std::vector<int> p)
subtask: the subtask number, where ;- : the number of the last floor;
- : the current floor, where ;
- : the value on floor ;
- : the currently pressed buttons, in increasing order.
This function is called when the elevator opens on floor , which happens when or the button for was pressed at an earlier stop. It is not called for a floor at which the elevator does not stop.
The return value is the list of new buttons to press. Their order is irrelevant. Every returned button must satisfy:
- ;
- is not already in and appears exactly once in the returned array.
std::vector<int> answer(int subtask, int N, std::vector<int> p)
subtask: the subtask number, where ;- : the number of the last floor;
- : the final set of pressed buttons, in increasing order.
This function is called exactly once per test case when the elevator reaches the rooftop.
The returned array must have length . Its -th element must equal if Karlsson can recover that value, and otherwise.
Important: The people in the building cannot communicate in any other way. Your program is run as separate processes: one for each floor and one for the rooftop. Each floor process receives at most calls to press_buttons; the rooftop process receives exactly calls to answer. Do not assume any shared state, including global variables. Every process has its own 64 MiB memory limit, and all calls, up to calls to press_buttons and exactly calls to answer, must finish within 10 seconds.
Input Format
The sample grader makes all function calls for all test cases in one execution.
Input format:
- line : , , and the subtask number ;
- line : integers for test case .
Output Format
Output format:
- line : the number of correctly recovered values in test case ;
- line : the final score.
For detailed feedback, change the macro DETAILED from false to true on the first line of the grader. To let the grader generate values of , change AUTO_GENERATE from false to true on its second line.
Hint
Example
The example has one test case with the following floor values:
1 1 0 1 1 1 1 1 1 0 1 1 1 0 1 0 1 0 1 1 0 1 1 0 1 0 1 0 1 1 1
1 0 1 1 0 1 1 1 0 1 0 1 0 1 1 0 1 0 1 1 1 1 0 1 1 1 1 0 1 1
An example interaction is:
| Participant program | Jury program |
|---|---|
press_buttons(0, 60, 0, 1, {}) |
|
return {2} |
|
press_buttons(0, 60, 2, 0, {2}) |
|
return {13, 42} |
|
press_buttons(0, 60, 13, 0, {2, 13, 42}) |
|
return {} |
|
press_buttons(0, 60, 42, 1, {2, 13, 42}) |
|
return {} |
|
answer(0, 60, {2, 13, 42}) |
|
return {1, -1, 0, -1, -1, ..., -1} |
This interaction correctly recovers values and . Every other returned value is because Karlsson did not recover it.
Constraints
- for every
Subtasks
| Subtask | Points | Additional constraints | Floors to recover for full points |
|---|---|---|---|
| 0 | The example. | - | |
| 1 | 15 | ; ; if , then for every | 60 |
| 2 | 35 | 40 | |
| 3 | 15 | 30 | |
| 4 | 35 | 25 | |
Scoring
If your program returns an incorrectly recovered value or performs an invalid operation, such as returning a vector of the wrong length, in any test case of a subtask, it receives zero points for that subtask.
For one test case, the recovered count is the number of returned positions that are not . Let be the minimum recovered count over all test cases of a subtask. Each subtask contains one test with at most test cases. Its score is:
| Subtask | Range of | Points |
|---|---|---|
| 0 | - | |
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||