Codeforces Round 1066 (Div. 1 + Div. 2)
C
Meximum Array 2
Codeforces
1400
原题
← BD →
翻译中…

You are given three positive integers $n$, $k$, and $q$. You are also given $q$ tuples $(c, l, r)$, with $1 \leq c \leq 2$ and $1 \leq l \leq r \leq n$.

翻译中…

An array $a_1, a_2, \ldots, a_n$ is meximum if $0 \leq a_i \leq 10^9$ for each $i$ in $[1, n]$, and for each given tuple $(c, l, r)$,

翻译中…
  • if $c = 1$, then $\min(a_l, a_{l+1}, \ldots, a_r) = k$;
  • if $c = 2$, then $\operatorname{MEX}$$^{\text{∗}}$$(a_l, a_{l+1}, \ldots, a_r) = k$.
翻译中…

Note that the parameter $k$ is the same for all the conditions.

翻译中…

Find a meximum array $a_1, a_2, \ldots, a_n$ of length $n$. The input is generated in such a way that a valid array always exists. If there are multiple possible arrays, you can print any one of them.

翻译中…

$^{\text{∗}}$The minimum excluded (MEX) of a collection of integers $a_1, a_2, \ldots, a_k$ is defined as the smallest non-negative integer $x$ which does not occur in the collection $a$.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

翻译中…

The first line of each test case contains three integers $n$, $k$, $q$ ($1 \leq k \leq n \leq 100$, $1 \leq q \leq 100$) — the length of the array $a_1, a_2, \ldots, a_n$, the result of the $\min$ and $\operatorname{MEX}$ calculations described by the tuples, and the number of tuples.

翻译中…

Then, $q$ lines follow. The $i$-th line contains a tuple $(c, l, r)$, which gives a constraint to $a_l, a_{l+1}, \ldots, a_r$ according to the statement.

翻译中…

It is guaranteed that there exists a valid array corresponding to the given input.

翻译中…

Note that there are no constraints on the sum of $n$, $k$, or $q$ over all test cases.

翻译中…

Output

翻译中…

For each test case, print a single line containing a meximum array $a_1, a_2, \ldots, a_n$.

翻译中…

Note

翻译中…

In the first test case, you have to build a meximum array with $n = 6$, $k = 2$ and with $q = 2$ constraints given by tuples.

翻译中…
  • tuple $(1, 1, 3)$: $\min(a_1, a_2, a_3)$ must be $2$;
  • tuple $(2, 2, 6)$: $\operatorname{MEX}(a_2, a_3, a_4, a_5, a_6)$ must be $2$.
翻译中…

A possible array that satisfies all these constraints, and has elements $0 \leq a_i \leq 10^9$, is $[2, 5, 4, 3, 0, 1]$.

翻译中…

In the second test case, you have to build a meximum array with $n = 3$, $k = 3$ and with $q = 1$ constraint given by a tuple.

翻译中…
  • tuple $(2, 1, 3)$: $\operatorname{MEX}(a_1, a_2, a_3)$ must be $3$.
翻译中…

A possible array that satisfies this constraint, and has elements $0 \leq a_i \leq 10^9$, is $[2, 0, 1]$.

翻译中…

样例

Input #1
4
6 2 2
1 1 3
2 2 6
3 3 1
2 1 3
3 3 2
1 1 1
1 3 3
3 2 2
2 1 2
2 2 3
Output #1
2 5 4 3 0 1
2 0 1
3 3 3
1 0 1
InputCopy OutputCopy
题目信息
题号
2157C
时间限制
2 s
内存限制
256 MB
标签
构造
贪心
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。