#P17333. 「TPOI-2C」Secret Illumination
「TPOI-2C」Secret Illumination
Background
Problem Description
Given , construct an array of length that satisfies the following conditions.
- .
- $\displaystyle\sum_{i=1}^{n}\sum_{j=i+1}^{n}[a_i < a_j]\times a_j = k$.
Here, when the condition holds, the value of is ; otherwise it is .
This problem uses Special Judge. Any answer that satisfies the conditions will be considered correct.
Input Format
This problem has multiple test cases.
The first line contains a positive integer , representing the number of test cases.
The next lines each contain two integers .
Output Format
For each test case, output one line: if there is a solution, output integers representing your constructed answer; if there is no solution, output -1.
4
4 15
7 1
3 21
10 1145141919810
2 3 1 4
-1
2009 12 21
-1
Hint
[Sample #1 Explanation]
For the first test case, we have . Another valid answer is 4 2 1 5, and the value of the expression in the statement is also exactly .
For the second test case, it is clearly impossible to construct a valid answer.
[Constraints]
This problem uses bundled tests.
| Score | Special property | |
|---|---|---|
| Sample | ||
| None | ||
For of the testdata, it is guaranteed that , , and .
Note: Incorrect code may cause Special Judge to exceed the time limit, in which case the result will be shown as UKE. Please be sure to take note.
Translated by ChatGPT 5