8685: Longest Increasing Subsequence

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:3 通过:1

题目描述


Given an integer mmm, you need to construct a permutation ppp whose length does not exceed 100100100 such that there are exactly mmm longest increasing subsequences in ppp.

If multiple solutions exist, print any of them. If no solution exists, report it.



输入格式

-

The first line contains an integer TTT (1≤T≤1000)(1\le T \le 1\,000)(1T1000), denoting the number of test cases.
Each test case contains an integer mmm (1≤m≤109)(1\le m \le 10^9)(1m109) in one line.

输出格式


For each test case:
If no solution exists, print "-1" (without quotes) in one line.
Otherwise, print one integer nnn (1≤n≤100)(1\le n\le 100)(1n100) in the first line denoting the length of the permutation you construct. Then print nnn integers p1,p2,⋯,pnp_1, p_2, \cdots, p_np1,p2,,pn, (1≤pi≤n,∀1≤i<j≤n,pi≠pj)(1 \le p_i \le n, \forall \, 1 \le i < j \le n, p_i \neq p_j)(1pin,1i<jn,pi=pj) in the second line denoting the permutation you construct.

输入样例 复制

2
3
5

输出样例 复制

4
2 4 1 3
5
3 2 5 1 4

数据范围与提示

=

In the first test case, the length of the LIS (longest increasing subsequence) is 222, and the 333 LISs are {2,4},{2,3},{1,3}\{2, 4\}, \{2, 3\}, \{1, 3\}{2,4},{2,3},{1,3}.
In the second test case, the length of the LIS is 222, and the 555 LISs are {3,5},{3,4},{2,5},{2,4},{1,4}\{3, 5\}, \{3, 4\}, \{2, 5\}, \{2, 4\}, \{1, 4\}{3,5},{3,4},{2,5},{2,4},{1,4}.

分类标签