| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 3 초 | 1024 MB | 281 | 61 | 53 | 21.545% |
Aisha and Basma are two friends who correspond with each other. Aisha has a message $M,ドル which is a sequence of $S$ bits (i.e., zeroes or ones), that she would like to send to Basma. Aisha communicates with Basma by sending her packets. A packet is a sequence of 31ドル$ bits indexed from 0ドル$ to 30ドル$. Aisha would like to send the message $M$ to Basma by sending her some number of packets.
Unfortunately, Cleopatra compromised the communication between Aisha and Basma and is able to taint the packets. That is, in each packet Cleopatra can modify bits on exactly 15ドル$ indices. Specifically, there is an array $C$ of length 31ドル,ドル in which every element is either 0ドル$ or 1ドル,ドル with the following meaning:
The array $C$ contains precisely 15ドル$ ones and 16ドル$ zeroes. While sending the message $M,ドル the set of indices controlled by Cleopatra stays the same for all packets. Aisha knows precisely which 15ドル$ indices are controlled by Cleopatra. Basma only knows that 15ドル$ indices are controlled by Cleopatra, but she does not know which indices.
Let $A$ be a packet that Aisha decides to send (which we call the original packet). Let $B$ be the packet that is received by Basma (which we call the tainted packet). For each $i,ドル such that 0ドル ≤ i < 31$:
Immediately after sending each packet, Aisha learns what the corresponding tainted packet is.
After Aisha sends all the packets, Basma receives all the tainted packets in the order they were sent and has to reconstruct the original message $M$.
Your task is to devise and implement a strategy that would allow Aisha to send the message $M$ to Basma, so that Basma can recover $M$ from the tainted packets. Specifically, you should implement two procedures. The first procedure performs the actions of Aisha. It is given a message $M$ and the array $C,ドル and should send some packets to transfer the message to Basma. The second procedure performs the actions of Basma. It is given the tainted packets and should recover the original message $M$.
The first procedure you should implement is:
void send_message(std::vector<bool> M, std::vector<bool> C)
This procedure should call the following procedure to send a packet:
std::vector<bool> send_packet(std::vector<bool> A)
send_message.The second procedure you should implement is:
std::vector<bool> receive_message(std::vector<std::vector<bool>> R)
send_message call and are given in the order they were sent by Aisha. Each element of $R$ is an array of length 31ドル,ドル representing a tainted packet.send_message call. The order of receive_message procedure calls is not necessarily the same as the order of the corresponding send_message calls.Note that in the grading system the send_message and receive_message procedures are called in two separate programs.
If in any of the test cases, the calls to the procedure send_packet do not conform to the rules mentioned above, or the return value of any of the calls to procedure receive_message is incorrect, the score of your solution for that test case will be 0ドル$.
Otherwise, let $Q$ be the maximum number of calls to the procedure send_packet among all invocations of send_message over all test cases. Also let $X$ be equal to:
Then, the score is calculated as follows:
| Subtask | Score | Additional Constraints |
|---|---|---|
| 1 | 10ドル \cdot X$ | $S ≤ 64$ |
| 2 | 90ドル \cdot X$ | No additional constraints. |
Note that in some cases the behaviour of the grader can be adaptive. This means that the values returned by send_packet may depend not just on its input arguments but also on many other things, including the inputs and return values of the prior calls to this procedure and pseudorandom numbers generated by the grader. The grader is deterministic in the sense that if you run it twice and in both runs you send the same packets, it will make the same changes to them.
Consider the following call.
send_message([0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
The message that Aisha tries to send to Basma is $[0, 1, 1, 0]$. The bits with indices from 0ドル$ to 15ドル$ cannot be changed by Cleopatra, while the bits with indices from 16ドル$ to 30ドル$ can be changed by Cleopatra.
For the sake of this example, let us assume that Cleopatra fills consecutive bits she controls with alternating 0ドル$ and 1ドル,ドル i.e. she assigns 0ドル$ to the first index she controls (index 16ドル$ in our case), 1ドル$ to the second index she controls (index 17ドル$), 0ドル$ to the third index she controls (index 18ドル$), and so on.
Aisha can decide to send two bits from the original message in one packet as follows: she will send the first bit at the first 8ドル$ indices she controls and the second bit at the following 8ドル$ indices she controls.
Aisha then chooses to send the following packet:
send_packet([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
Note that Cleopatra can change bits with the last 15ドル$ indices, so Aisha can set them arbitrarily, as they might be overwritten. With the assumed strategy of Cleopatra, the procedure returns: $[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]$.
Aisha decides to send the last two bits of $M$ in the second packet in a similar way as before:
send_packet([1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
With the assumed strategy of Cleopatra, the procedure returns: $[1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]$.
Aisha can send more packets, but she chooses not to.
The grader then makes the following procedure call:
receive_message([[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]])
Basma recovers message $M$ as follows. From each packet she takes the first bit that occurs twice in a row, and the last bit that occurs twice in a row. That is, from the first packet, she takes bits $[0, 1],ドル and from the second packet she takes bits $[1, 0]$. By putting them together, she recovers the message $[0, 1, 1, 0],ドル which is the correct return value for this call to receive_message.
It can be shown that with the assumed strategy of Cleopatra and for messages of length 4ドル,ドル this approach of Basma correctly recovers $M,ドル regardless of the value of $C$. However, it is not correct in the general case.
The sample grader is not adaptive. Instead, Cleopatra fills consecutive bits she controls with alternating 0ドル$ and 1ドル$ bits, as described in the example above.
Input format: The first line of the input contains an integer $T,ドル specifying the number of scenarios. $T$ scenarios follow. Each of them is provided in the following format:
S M[0] M[1] ... M[S-1] C[0] C[1] ... C[30]
Output format: The sample grader writes the result of each of the $T$ scenarios in the same order as they are provided in the input in the following format:
K L D[0] D[1] ... D[L-1]
Here, $K$ is the number of calls to send_packet, $D$ is the message returned by receive_message and $L$ is its length.
Olympiad > International Olympiad in Informatics > IOI 2024 > Day 1 2번
C++17, C++20, C++17 (Clang), C++20 (Clang)