CF BUDDY
← Problems·

1990B · Array Craft

1200 · constructive algorithms, greedy

Problem: For an array bb of size mm, we define:

  • the maximum prefix position of bb is the smallest index ii that satisfies b1++bi=maxj=1m(b1++bj)b_1+\ldots+b_i=\max_{j=1}^{m}(b_1+\ldots+b_j);
  • the maximum suffix position of bb is the largest index ii that satisfies bi++bm=maxj=1m(bj++bm)b_i+\ldots+b_m=\max_{j=1}^{m}(b_j+\ldots+b_m).

You are given three integers nn, xx, and yy (x>yx > y). Construct an array aa of size nn satisfying:

  • aia_i is either 11 or 1-1 for all 1in1 \le i \le n;
  • the maximum prefix position of aa is xx;
  • the maximum suffix position of aa is yy.

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 Format: The first line contains an integer tt (1t1041 \leq t \leq 10^4) — the number of test cases.

For each test case:

  • The only line contains three integers nn, xx, and yy (2n105,1y<xn)2 \leq n \leq 10^5, 1 \le y \lt x \le n).

It is guaranteed that the sum of nn over all test cases will not exceed 10510^5.

Output Format: For each test case, output nn space-separated integers a1,a2,,ana_1, a_2, \ldots, a_n in a new line.

Note: In the second test case,

  • i=x=4i=x=4 is the smallest index that satisfies a1++ai=maxj=1n(a1++aj)=2a_1+\ldots +a_i=\max_{j=1}^{n}(a_1+\ldots+a_j)=2;
  • i=y=3i=y=3 is the greatest index that satisfies ai++an=maxj=1n(aj++an)=2a_i+\ldots +a_n=\max_{j=1}^{n}(a_j+\ldots+a_n)=2.

Thus, the array a=[1,1,1,1]a=[1,-1,1,1] is considered correct.

Sample Cases

Case 1

Input

3
2 2 1
4 4 3
6 5 1

Output

1 1
1 -1 1 1
1 1 -1 1 1 -1

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback