Logo
(追記) (追記ここまで)

29741번 - Coreputer 서브태스크점수다국어언어 제한함수 구현

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.5 초 1024 MB3910926.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)
  • $N$: the number of cores.
  • This procedure should return an array $c = [c[0], c[1], \dots , c[N - 1]],ドル where for each $i$ from 0ドル$ to $N - 1,ドル inclusive, $c[i] = 1$ if core $i$ is malfunctioning, and $c[i] = 0$ otherwise.
  • This procedure is called exactly once for each test case.

The above procedure can make calls to the following procedure:

int run_diagnostic(int[] T)
  • $T$: an array of distinct cores.
  • This procedure returns
    • 1ドル$ if there are more tagged cores than untagged cores which are malfunctioning;
    • 0ドル$ if the number of tagged and untagged malfunctioning cores are equal;
    • $-1$ if there are fewer tagged cores than untagged cores which are malfunctioning.
  • This procedure can be called at most 32ドル$ times in each test case.

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]$.

입력

출력

제한

  • 2ドル ≤ N ≤ 16$

서브태스크

번호배점제한
120

$N = 2$

240

The number of malfunctioning cores is even.

340

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:

  • line 1ドル$: $N$
  • line 2ドル$: $M[0]$ $M[1]$ $\dots$ $M[N - 1]$

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$
    • has more than $N$ elements, or
    • contains an element that is not an integer between 0ドル$ and $N - 1,ドル inclusive, or
    • contains the same element at least twice.
  • 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:

  • line 1ドル$: $c[0]$ $c[1]$ $\dots$ $c[n - 1]$
  • line 2ドル$: the number of calls to run_diagnostic

첨부

출처

Olympiad > International Olympiad in Informatics > IOI 2023 > Practice 3번

제출할 수 있는 언어

C++17, C++20, C++17 (Clang), C++20 (Clang)

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /