| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 0.5 초 | 1024 MB | 39 | 10 | 9 | 26.471% |
Coreputer, the brand new computing machine has $N$ cores numbered from 0ドル$ to $N - 1$. Recent maintenance revealed that some of the cores are malfunctioning. It is unknown which specific cores are malfunctioning, but there is at least one malfunctioning core.
To find the malfunctioning cores, Coreputer can run diagnostic scans. In each scan, the user tags a (possibly empty) group of distinct cores $T[0],\dots ,T[l - 1]$ for some 0ドル ≤ l ≤ N$. The rest of the cores are untagged. Coreputer then benchmarks the tagged cores and the untagged ones. Finally, it reports which of the two groups contains a greater number of malfunctioning cores, or that the two groups contain an equal number of malfunctioning cores. Note that an empty group contains 0 malfunctioning cores.
Your task is to find the malfunctioning cores by running diagnostic scans on Coreputer.
You should implement the following procedure.
int[] malfunctioning_cores(int N)
The above procedure can make calls to the following procedure:
int run_diagnostic(int[] T)
The grader is not adaptive, meaning that the set of malfunctioning cores is fixed before a call to malfunctioning_cores is made.
Consider a scenario when there are $N = 4$ cores, and only core 2ドル$ is malfunctioning.
Procedure malfunctioning_cores is called the following way:
malfunctioning_cores(4)
The procedure may call run_diagnostic as follows.
| Call | Tagged cores | Untagged cores | Return value |
|---|---|---|---|
run_diagnostic([0]) |
0ドル$ | 1,2,3ドル$ | $-1$ |
run_diagnostic([1, 2]) |
1,ドル 2$ | 0,ドル 3$ | 1ドル$ |
run_diagnostic([2]) |
2ドル$ | 0,ドル 1, 3$ | 1ドル$ |
In the first call, there are no malfunctioning tagged cores, and one untagged core is malfunctioning, so the procedure returns $-1$.
After the third call returns 1ドル,ドル it is clear that at least one tagged core (that is, core 2ドル$) is malfunctioning. But then, the number of untagged malfunctioning cores must be zero, so we conclude that no other core is malfunctioning.
Therefore, the procedure malfunctioning_cores should return $[0, 0, 1, 0]$.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 20 | $N = 2$ |
| 2 | 40 | The number of malfunctioning cores is even. |
| 3 | 40 | No additional constraints. |
If, in any of the test cases, the calls to the procedure run_diagnostic do not conform to the constraints described in Implementation Details, or the return value of malfunctioning_cores is incorrect, the score of your solution for that subtask will be 0ドル$.
In each subtask, you can obtain a partial score. Let $q$ be the maximum number of calls to the procedure run_diagnostic among all test cases. Then, you will get a percentage of the subtask's score according to the following table:
| Condition | Percentage |
|---|---|
| 24ドル < q ≤ 32$ | 50ドル%%$ |
| 18ドル < q ≤ 24$ | 75ドル%%$ |
| $q ≤ 18$ | 100ドル%%$ |
The sample grader reads the input in the following format:
where for each $i$ from 0ドル$ to $N - 1,ドル inclusive, $M[i] = 1$ if core $i$ is malfunctioning, and $M[i] = 0$ otherwise.
Before calling malfunctioning_cores, the sample grader checks whether there is at least one malfunctioning core. If this condition is not met, it prints the message No Malfunctioning Cores and terminates.
If the sample grader detects a protocol violation, the output of the sample grader is Protocol Violation: <MSG>, where <MSG> is one of the error messages:
invalid array: in a call to run_diagnostic, array $T$
too many calls: the number of calls made to run_diagnostic exceeds 32ドル$.Otherwise, let the elements of the array returned by malfunctioning_cores be $c[0], c[1], \dots , c[n - 1]$ for some nonnegative $n$. The output of the sample grader is in the following format:
run_diagnosticC++17, C++20, C++17 (Clang), C++20 (Clang)