QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 512 MB 満点: 100 ハック可能 ✓

#17774. Yearbook Organization

統計

There are $n$ yearbooks on a bookshelf. Initially, the damage level of the $i$-th ($1 \le i \le n$) yearbook is $a_i$.

In each move, you must first choose a position $p$ ($1 \le p \le n - 1$), and then move the $(p+1)$-th yearbook to the position immediately before the $p$-th yearbook. After this move, the damage level of that yearbook increases by $1$.

Due to limited time, you can perform at most $n^2 - n$ moves in total. As one of the participants who browsed the yearbooks, you need to help Xiao S plan a specific sequence of moves such that the damage levels of the yearbooks on the shelf are strictly increasing from left to right.

Input

Each test case contains multiple test sets. The first line of the input contains a positive integer $T$ ($1 \le T \le 10$), representing the number of test sets. For each test set:

  • The first line contains a positive integer $n$ ($2 \le n \le 500$), representing the number of yearbooks.
  • The second line contains $n$ positive integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$), representing the initial damage level of each yearbook.

Output

For each test set, if a feasible sequence of moves exists:

  • The first line outputs a non-negative integer $k$ ($0 \le k \le n^2 - n$), representing the number of moves.
  • The second line outputs $k$ positive integers $p_1, p_2, \dots, p_k$ ($1 \le p_i \le n - 1$), representing the chosen position for each move.

If it is impossible to make the damage levels of the yearbooks on the shelf strictly increasing from left to right, output a single integer $-1$.

Examples

Input 1

3
2
1 2
2
2 1
3
4 5 1

Output 1

0

-1
2
2 1

Note

For the first test set, the damage levels of the yearbooks on the shelf are already strictly increasing from left to right initially.

For the second test set, it can be proven that it is impossible to make the damage levels strictly increasing from left to right within $n^2 - n$ moves.

For the third test set, one feasible sequence of moves is as follows: The first move chooses position $2$, and the damage levels of all yearbooks become $[4, 2, 5]$. The second move chooses position $1$, and the damage levels of all yearbooks become $[3, 4, 5]$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.