| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 63 | 31 | 30 | 49.180% |
Adam is making Bob a hand-crafted necklace as a gift. A necklace consists of $n$ beads, numbered 0ドル$ to $n-1$ from left to right. Each bead can either be red or blue in colour. Bob has sent Adam a list of $r$ requirements for the necklace. The $i$th requirement (0ドル \leq i \lt r$) states that the beads from positions $a[i]$ to $b[i]$ inclusive should have $x[i]$ unique colours.
Help Adam find a possible configuration of beads that satisfies all of Bob's requirements, or determine that it is impossible.
You should implement the following procedure:
int construct(int n, int r, int[] a, int[] b, int[] x)
craft to report the construction, following which it should return 1ドル$.craft.Your program should call the following procedure to report the construction:
void craft(string s)
Consider the following call:
construct(4, 2, [0, 2], [2, 3], [1, 2])
This means that there are a total of 4ドル$ beads and 2ドル$ requirements as follows:
This can be achieved by colouring beads 0ドル$ to 2ドル$ red, and bead 3ドル$ blue.
Therefore, the construct procedure should make the following call:
craft("RRRB")It should then return 1ドル$.
In this case, there are multiple constructions that fit the requirements, all of which would be considered correct.
Consider the following call:
construct(3, 3, [0, 1, 0], [1, 2, 2], [1, 1, 2])
This means that there are a total of 3ドル$ beads and 3ドル$ requirements as follows:
In this case, there are no possible configuration of beads that satisfy all the requirements.
As such, the construct procedure should return 0ドル$ without making any call to craft.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 10 | $x[i] = 1$ (for all 0ドル \leq i \leq n-1$) |
| 2 | 15 | $x[i] = 2$ (for all 0ドル \leq i \leq n-1$) |
| 3 | 20 | 1ドル \leq n, r \leq 18$ |
| 4 | 25 | 1ドル \leq n, r \leq 2000$ |
| 5 | 30 | No additional constraints. |
Olympiad > International Olympiad in Informatics > IOI 2021 > Practice 1번
Olympiad > International Olympiad in Informatics > IOI 2020 > Practice 1번
C++17, C++14, C++20, C++14 (Clang), C++17 (Clang), C++20 (Clang)