| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 2048 MB | 47 | 8 | 8 | 17.021% |
Alicia and Beatriz are preparing a magic trick for the IOI Talent Show. The trick works as follows:
Your task is to devise and implement a strategy for Alicia and Beatriz. The more impressive the trick, the better your score: the objective is to maximize $K,ドル the number of hidden cards Beatriz can correctly reveal.
The first procedure that you have to implement:
std::vector<int> Alicia(std::vector<int> P)
This procedure should return an array $Q$ of length $N,ドル representing the card flips Alicia performs. For each index $i$ (0ドル ≤ i ≤ N − 1$), the values in $Q$ must be set as follows:
The second procedure that you have to implement:
std::vector<int> Beatriz(std::vector<int> Q)
Alicia. This array specifies the configuration of the cards when Beatriz enters.This procedure should return an array $B$ of length $N,ドル representing the original permutation $P,ドル that is, $B[i] = P[i]$ should hold for each $i$ (0ドル ≤ i ≤ N − 1$).
In each test case, the two procedures are called exactly once, as follows:
Alicia is called with the original permutation $P$.Alicia:
Wrong Answer verdict.Beatriz is called with the array $Q$.Let $M$ be the minimum value of $K$ for which your solution successfully performs the trick across all test cases.
In particular, a full score is achieved if $M = 16$.
Consider a scenario where $N = 6$ and $P = [2, 4, 3, 1, 5, 6]$. The procedure Alicia is called as:
Alicia([2, 4, 3, 1, 5, 6])
Suppose Alicia uses the following strategy: flip every card $i$ such that $P[i] = i + 1$. In this case, the condition holds for$ i = 2, 4,ドル and 5ドル$. Hence, the procedure returns the array $[2, 4,−1, 1,−1,−1]$.
Now, the procedure Beatriz is called as:
Beatriz([2, 4, -1, 1, -1, -1])
Knowing the strategy of Alice, she finds and returns the original array $P = [2, 4, 3, 1, 5, 6]$.
In this case, $K = 3,ドル as three cards were flipped. However, if submitted, this strategy would receive a score of 0ドル,ドル because there exist permutations where no index $i$ satisfies $P[i] = i + 1$.
Note that this example does not satisfy the constraint $N = 256$ and therefore will not be used during grading. The downloadable attachment for this task includes a sample input for the grader with $N = 256$. The same permutation $P$ is used in Subtask 0 during evaluation.
Input format:
N P[0] P[1] ... P[N-1]
Output format:
S Q[0] Q[1] ... Q[S-1] T B[0] B[1] ... B[T-1]
Here:
Alicia.Beatriz.Note that while $N = 256$ holds for all testcases in this task, you may use the sample grader with any value of $N$.
C++17, C++20, C++23, C++26, C++17 (Clang), C++20 (Clang)