Codeforces Round 960 (Div. 2)
翻译中…
For an array $b$ of size $m$, we define:
翻译中…
- the maximum prefix position of
$b$is the smallest index$i$that satisfies$b_1+\ldots+b_i=\max_{j=1}^{m}(b_1+\ldots+b_j)$; - the maximum suffix position of
$b$is the largest index$i$that satisfies$b_i+\ldots+b_m=\max_{j=1}^{m}(b_j+\ldots+b_m)$.
翻译中…
You are given three integers $n$, $x$, and $y$ ($x \gt y$). Construct an array $a$ of size $n$ satisfying:
翻译中…
$a_i$is either$1$or$-1$for all$1 \le i \le n$;- the maximum prefix position of
$a$is$x$; - the maximum suffix position of
$a$is$y$.
翻译中…
If there are multiple arrays that meet the conditions, print any. It can be proven that such an array always exists under the given conditions.
翻译中…
Input
翻译中…
The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.
翻译中…
For each test case:
翻译中…
- The only line contains three integers
$n$,$x$, and$y$($2 \leq n \leq 10^5, 1 \le y \lt x \le n)$.
翻译中…
It is guaranteed that the sum of $n$ over all test cases will not exceed $10^5$.
翻译中…
Output
翻译中…
For each test case, output $n$ space-separated integers $a_1, a_2, \ldots, a_n$ in a new line.
翻译中…
Note
翻译中…
In the second test case,
翻译中…
$i=x=4$is the smallest index that satisfies$a_1+\ldots +a_i=\max_{j=1}^{n}(a_1+\ldots+a_j)=2$;$i=y=3$is the greatest index that satisfies$a_i+\ldots +a_n=\max_{j=1}^{n}(a_j+\ldots+a_n)=2$.
翻译中…
Thus, the array $a=[1,-1,1,1]$ is considered correct.
翻译中…
样例
Input #1
3
2 2 1
4 4 3
6 5 1
Output #1
1 1
1 -1 1 1
1 1 -1 1 1 -1
InputCopy
OutputCopy
题目信息
标签
构造
贪心
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。