majorat

Time limit: 2s Memory limit: 256MB Input: Output:

Task

You are given a positive integer KK. Construct a sequence that has exactly KK subarrays, not necessarily disjoint, each admitting a majority element.

An element is considered a majority in a sequence of NN numbers if it appears at least N2+1\lfloor \frac{N}{2} \rfloor + 1 times.

The elements of the sequence must be positive integers between 00 and the length of the sequence (inclusive).

Any sequence whose length belongs to the interval [LOW,HIGH][LOW, HIGH], where LOWLOW and HIGHHIGH are specified in the problem constraints, is considered correct and will be scored accordingly.

You need to solve the problem for TT scenarios.

Input data

The first line of the input file contains the number TT.
The next TT lines each contain a positive integer KK, as described in the statement.

Output data

The output file will contain the solution for each of the TT scenarios. For each scenario, two lines will be displayed in the following format:

The first line will contain the length of the found sequence. The second line will contain the elements of the sequence, separated by a space.

Constraints and clarifications

  • 1K1 000 000 0001 \leq K \leq 1 \ 000 \ 000 \ 000.
  • For sequences with a length less than or equal to LOWLOW, the maximum score will be awarded.
  • For sequences with lengths in the interval [LOW+1,HIGH][LOW + 1, HIGH], between 2020 and 8080 percent of the score will be awarded according to the formula 80(HIGHN)+20(NLOW)HIGHLOW\frac{80 \cdot (HIGH - N) + 20 \cdot (N - LOW)}{HIGH - LOW}.
  • For sequences longer than HIGHHIGH, zero points will be awarded.
  • In a test case, the final score is the minimum obtained across all TT scenarios.
  • It is guaranteed that a solution always exists that satisfies the problem constraints.
  • 1HIGH1071 \leq \sum{HIGH} \leq 10^7
# Score Restrictions
1 30 1K1031 \leq K \leq 10^3, LOW=200LOW = 200, HIGH=103HIGH = 10^3.
2 30 1K1071 \leq K \leq 10^7, LOW=1.3104LOW = 1.3 \cdot 10^4, HIGH=105HIGH = 10^5
3 40 1K1091 \leq K \leq 10^9, LOW=1.3105LOW = 1.3 \cdot 10^5, HIGH=106HIGH = 10^6

Example 1

stdin

1
2

stdout

2
0 1

Explanation

For the first example, for the sequence {0,10, 1}, the subsequences are: {00} and {11}.

Example 2

stdin

2
5
2

stdout

3
1 0 0
2
1 2

Explanation

For the second example, for the sequence {1,0,0}\{1, 0, 0\}, the subsequences are: {1}\{1\}, {0}\{0\}, {0}\{0\}, {0,0}\{0, 0\}, and {1,0,0}\{1, 0, 0\}. For the sequence {1,2}\{1, 2\}, the subsequences are: {1}\{1\} and {2}\{2\}.

Log in or sign up to be able to send submissions!