All submissions for this problem are available.
You are given an integer N. Consider a vector a of length N2 accessible via 0-based indexing.
Let's call the following transformation a TVT-transformation (Terrible Vector transformation).
We will call a vector g a good vector if
For some reason, you want to find a vector a of length N2 such that it's elements are either 1 or -1 and after applying TVT-transformation (i.e. b), it results in a good vector.
The first line of input contains an integer T denoting the number of test cases. Each test case is described by one line containing one integer N.
For each test case output one line with the word NO if it's not possible to find such vector. Otherwise output YES on the first line and N2 space-separated integers (each either -1 or 1) on the second - the answer for this test case.
If there are multiple possible answers, output any one of them.
- 1 ≤ T ≤ 100
- 1 ≤ N ≤ 100
Input: 2 1 2 Output: YES 1 YES 1 1 1 -1
Subtask 1:(10 points)
- 1 ≤ N ≤ 8
Subtask 2: (20 points)
- 1 ≤ N ≤ 30
Subtask 3: (30 points)
- 1 ≤ N ≤ 60
Subtask 4: (40 points)
- 1 ≤ N ≤ 100
Sample example 2: After TVT-transformation, the vector will transform to (4, 0, 0, 4) which is a good vector for N = 2
|Tags||hadamard, hard, matrices, paley-const, pavel1996, sept15, sylvesters, williamson|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.