Codeforces Round 1044 (Div. 2)
F
Flint and Steel
Codeforces
3000
原题
← E→
翻译中…

Steve's creeper farm has overflowed and there are creepers everywhere! There are $n$ creepers standing in a line, with the $i$-th creeper having explosive power $e_i$. Steve needs to kill all of them in order to get past.

翻译中…

To do this, he can use his trusty Flint and Steel to detonate creepers. Detonating the creeper at position $i$ kills all creepers at positions $j$ such that $|i - j| \lt e_i$. Dead creepers cannot be detonated. Some creepers may be particularly weak and have explosive power $0$, meaning they cannot be detonated either.

翻译中…

With the Great Hog hot on his tail, there is no time to waste. Find a sequence of detonations that kills all the creepers with as few detonations as possible, or report it is impossible.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line of each test case contains a single integer $n$ ($2 \le n \le 5 \cdot 10^5$) — the number of creepers.

翻译中…

The second line of each test case contains $n$ integers $e_1, e_2,\ldots, e_n$ ($0 \le e_i \le n$) — the explosive power of each creeper.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $5 \cdot 10^5$.

翻译中…

Output

翻译中…

For each test case, output $-1$ if it is impossible to kill all the creepers.

翻译中…

Otherwise, output two lines. On the first line, output a single integer $k$ ($1 \leq k \leq n$), the minimum number of detonations needed. Then output a line with $k$ integers $d_1, d_2, \ldots, d_k$ ($1 \leq d_i \leq n$), stating the sequence of creepers to detonate.

翻译中…

If there are multiple solutions, you can print any of them.

翻译中…

Note

翻译中…

In the first test case, the sequence of detonations is as follows:

翻译中…
  • $\underline{0, \mathbf{2}, 2}, 3, 0, 1$
  • $\times, \underline{\times, \times, \mathbf{3}, 0, 1}$
  • $\times, \times, \times, \times, \times, \times$
翻译中…

where $\times$ represents a dead creeper. Note that if Steve had first detonated creeper $4$ instead, the only creeper left alive would be creeper $1$ which cannot be detonated.

翻译中…

In the second test case, creeper $1$ cannot be detonated, and none of creepers $2$, $3$ or $4$ have a high enough explosive power to kill it, so there is no solution.

翻译中…

In the fifth test case, the sequence of detonations is as follows:

翻译中…
  • $\underline{\mathbf{2}, 0}, 2, 4, 2, 2, 4, 1, 1$
  • $\times, \times, 2, \underline{4, 2, 2, \mathbf{4}, 1, 1}$
  • $\times, \underline{\times, \mathbf{2}, \times}, \times, \times, \times, \times, \times$
  • $\times, \times, \times, \times, \times, \times, \times, \times, \times$
翻译中…

样例

Input #1
5
6
0 2 2 3 0 1
4
0 1 2 3
4
1 1 1 1
5
1 3 1 3 1
9
2 0 2 4 2 2 4 1 1
Output #1
2
2 4
-1
4
2 4 1 3
2
2 5
3
1 7 3
InputCopy OutputCopy
题目信息
题号
2133F
时间限制
2 s
内存限制
256 MB
标签
数据结构
动态规划
图论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。