시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 1024 MB | 44 | 24 | 23 | 54.762% |
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)