CF1823A.A-characteristic
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Consider an array a1,a2,…,an consisting of numbers 1 and −1 . Define A -characteristic of this array as a number of pairs of indices 1≤i<j≤n , such that ai⋅aj=1 .
Find any array a with given length n with A -characteristic equal to the given value k .
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t ( 1≤t≤100 ). The description of the test cases follows.
The only line of each test case contains two integers n and k ( 2≤n≤100 ; 0≤k≤2(n−1)n ) — the length of required array and required A -characteristic.
输出格式
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.
输入输出样例
输入#1
7 2 0 2 1 3 1 3 2 3 3 5 4 5 5
输出#1
YES 1 -1 YES 1 1 YES 1 -1 1 NO YES 1 1 1 YES -1 1 -1 1 1 NO
说明/提示
In the first test case, there is only one pair of different elements in the array, and their product is a1⋅a2=−1=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 a1⋅a2=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: a1⋅a2=−1 , a1⋅a3=1 , a2⋅a3=−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 .