CF2031C Penchick and BBQ Buns
题目描述
有 $n$ 个空位,你要用一些正整数来填充这些空位。
你用来填充空位的正整数 $k$ 必须满足以下两个条件:
- $k$ 至少出现两次。
填完空位之后,设第 $i$ 个空位上的数是 $a_i$。对于任意的 $i\le n$ 和 $j\le n$,如果 $i\ne j$ 且 $a_i=a_j$,那么 $|i-j|$ 是完全平方数。
你需要构造出一组合法的方案,或者报告无解。
输入格式
第一行输入一个整数 $t(1\le t\le 2\times 10^5)$,表示数据组数。
对于每一组数据,输入一行一个整数,表示 $n(1\le n\le 2\times 10^5)$。
保证 $\sum n\le 2\times 10^5$。
输出格式
对于每组测试数据,如果无解,输出一行一个整数 $-1$。
如果有解,输出一行 $n$ 个数,第 $i$ 个数表示 $a_i$。
### 样例解释
对于 $n=3$,可以证明无法找到合法解,因为不能构造出使用超过两种数且每种数出现次数大于等于 $2$ 的方案,而 $\{1,1,1\}$ 显然不是合法解,因为 $a_1=a_3$ 而 $3-1$ 不是完全平方数。
对于 $n=12$,显然样例输出是合法解:
$a_1=a_{10},10-1=9=3^2$
$a_2=a_{6},6-2=4=2^2$
$a_3=a_{12},12-3=9=3^2$
$a_4=a_{8},8-4=4=2^2$
$a_5=a_{9},9-5=4=2^2$
$a_7=a_{11},11-7=4=2^2$
说明/提示
In the first test case, the choice of fillings "1 1 1" is not allowed because buns $ 1 $ and $ 3 $ have the same filling, but are distance $ 2 $ apart, which is not a perfect square. The choice of fillings "1 1 2" is also not allowed as filling $ 2 $ is only used once.
In the second test case, the solution is valid because no filling is used exactly once, and any two buns with the same filling are spaced at a distance equal to a perfect square. For example, buns $ 1 $ and $ 10 $ both have filling $ 1 $ and are spaced at a distance of $ 9=3^2 $ . Similarly, buns $ 5 $ and $ 9 $ both have filling $ 10 $ and are spaced at a distance of $ 4=2^2 $ .