#P17274. [eJOI 2026] Elevator

    ID: 17393 Type: RemoteJudge 10000ms 64MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>交互题Special JudgeeJOI(欧洲)2026通信题

[eJOI 2026] Elevator

题目描述

This is a communication problem.

There is a building with floors numbered from 00 to NN. Floor 00 is the ground floor, and above floor NN is the rooftop. Thus, including the rooftop, the building has N+2N+2 levels.

Each floor ff with 0≤f≤N0\le f\le N is occupied by exactly one resident and has a secret integer vfv_f with 0≤vf≤30\le v_f\le 3, known only to that resident. Karlsson lives on the rooftop. His objective is to determine as many values among v0,v1,…,vNv_0,v_1,\ldots,v_N 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 00 and travels only upward. It has buttons labelled 11 through NN. Initially no buttons are pressed; once pressed, a button remains pressed permanently. The elevator stops and opens on floor ff if either f=0f=0 or the button for floor ff was pressed at an earlier stop. After visiting the highest floor whose button has been pressed, or floor 00 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 ff:

  1. The resident sees the complete set of buttons currently pressed.
  2. Based only on this information and on vfv_f, the resident may press any subset of the currently unpressed buttons for floors strictly above ff.
  3. 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 v0,v1,…,vNv_0,v_1,\ldots,v_N as possible.

The values of vv are fixed before your program starts and do not change during the process.

Implementation details

There are TT 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 0≤subtask≤40\le\texttt{subtask}\le 4;
  • NN: the number of the last floor;
  • ff: the current floor, where 0≤f≤N0\le f\le N;
  • vv: the value vfv_f on floor ff;
  • pp: the currently pressed buttons, in increasing order.

This function is called when the elevator opens on floor ff, which happens when f=0f=0 or the button for ff 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 xx must satisfy:

  • f<x≤Nf<x\le N;
  • xx is not already in pp 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 0≤subtask≤40\le\texttt{subtask}\le 4;
  • NN: the number of the last floor;
  • pp: 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 N+1N+1. Its ii-th element must equal viv_i if Karlsson can recover that value, and −1-1 otherwise.

Important: The people in the building cannot communicate in any other way. Your program is run as N+2N+2 separate processes: one for each floor and one for the rooftop. Each floor process receives at most TT calls to press_buttons; the rooftop process receives exactly TT 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 (N+1)T(N+1)T calls to press_buttons and exactly TT calls to answer, must finish within 10 seconds.

输入格式

The sample grader makes all function calls for all test cases in one execution.

Input format:

  • line 11: TT, NN, and the subtask number SS;
  • line 1+i1+i: N+1N+1 integers v0,v1,…,vNv_0,v_1,\ldots,v_N for test case ii.

输出格式

Output format:

  • line ii: the number of correctly recovered values in test case ii;
  • line T+1T+1: 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 vfv_f, change AUTO_GENERATE from false to true on its second line.

提示

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 00 and 22. Every other returned value is −1-1 because Karlsson did not recover it.

Constraints

  • N=60N=60
  • T≤10 000T\le 10\,000
  • 0≤vi≤30\le v_i\le 3 for every 0≤i≤N0\le i\le N

Subtasks

Subtask Points Additional constraints Floors to recover for full points
0 The example. -
1 15 0≤vi≤10\le v_i\le 1; v0=vN=1v_0=v_N=1; if vi=0v_i=0, then vi+1=1v_{i+1}=1 for every 0≤i<N0\le i<N 60
2 35 0≤vi≤10\le v_i\le 1 40
3 15 0≤vi≤20\le v_i\le 2 30
4 35 0≤vi≤30\le v_i\le 3 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 −1-1. Let KK be the minimum recovered count over all test cases of a subtask. Each subtask contains one test with at most 10 00010\,000 test cases. Its score is:

Subtask Range of KK Points
0 - 00
1 K<60K<60 0.25K0.25K
K≥60K\ge 60 1515
2 K<30K<30 0.5K0.5K
30≤K<4030\le K<40 2K−452K-45
K≥40K\ge 40 3535
3 K<30K<30 0.5K0.5K
K≥30K\ge 30 1515
4 K<20K<20 0.7K0.7K
20≤K<2520\le K<25 4K−664K-66
K≥25K\ge 25 3535