Codeforces Round 868 (Div. 2)
A
A-characteristic
Codeforces
800
原题
←B →
翻译中…

Consider an array $a_1, a_2, \dots, a_n$ consisting of numbers $1$ and $-1$. Define $A$-characteristic of this array as a number of pairs of indices $1 \le i \lt j \le n$, such that $a_i \cdot a_j = 1$.

翻译中…

Find any array $a$ with given length $n$ with $A$-characteristic equal to the given value $k$.

翻译中…

Input

翻译中…

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

翻译中…

The only line of each test case contains two integers $n$ and $k$ ($2 \le n \le 100$; $0 \le k \le \frac{(n-1) n}{2}$) — the length of required array and required $A$-characteristic.

翻译中…

Output

翻译中…

For each test case, if there is no array $a$ with given $A$-characteristic $k$, print NO.

翻译中…

Otherwise, print YES and $n$ numbers $1$ and $-1$, which form the required array $a$. If there are multiple answers, print any of them.

翻译中…

Note

翻译中…

In the first test case, there is only one pair of different elements in the array, and their product is $a_1 \cdot a_2 = -1 \neq 1$, hence its $A$-characteristic is $0$.

翻译中…

In the second test case, there is only one pair of different elements in the array, and their product is $a_1 \cdot a_2 = 1$, hence its $A$-characteristic is $1$.

翻译中…

In the third test case, there are three pairs of different elements in the array, and their product are: $a_1 \cdot a_2 = -1$, $a_1 \cdot a_3 = 1$, $a_2 \cdot a_3 = -1$, hence its $A$-characteristic is $1$.

翻译中…

In the fourth test case, we can show, that there is no array with length $3$, which $A$-characteristic is $2$.

翻译中…

样例

Input #1
7
2 0
2 1
3 1
3 2
3 3
5 4
5 5
Output #1
YES
1 -1
YES
1 1
YES
1 -1 1
NO
YES
1 1 1
YES
-1 1 -1 1 1
NO
InputCopy OutputCopy
题目信息
题号
1823A
时间限制
1 s
内存限制
256 MB
标签
组合数学
构造
数学

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