CF1876C.Autosynthesis
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Chaneka writes down an array a of n positive integer elements. Initially, all elements are not circled. In one operation, Chaneka can circle an element. It is possible to circle the same element more than once.
After doing all operations, Chaneka makes a sequence r consisting of all uncircled elements of a following the order of their indices.
Chaneka also makes another sequence p such that its length is equal to the number of operations performed and pi is the index of the element that is circled in the i -th operation.
Chaneka wants to do several operations such that sequence r is equal to sequence p . Help her achieve this, or report if it is impossible! Note that if there are multiple solutions, you can print any of them.
输入格式
The first line contains a single integer n ( 1≤n≤2⋅105 ) — the size of array a .
The second line contains n integers a1,a2,a3,…,an ( 1≤ai≤n ).
输出格式
A single line containing −1 if it is impossible.
Otherwise, the output consists of two lines. The first line contains an integer z representing the number of operations performed. The second line contains z integers, the i -th integer represents the index of the element circled in the i -th operation. If there are multiple solutions, you can print any of them.
输入输出样例
输入#1
5 3 4 2 2 3
输出#1
3 3 2 3
输入#2
3 1 2 3
输出#2
-1
说明/提示
In the first example, doing the operations like the example output gives the following results:
- Element a2 gets circled 1 time.
- Element a3 gets circled 2 times.
- The uncircled elements (ordered by their indices) are a1 , a4 , and a5 . So r=[3,2,3] .
- p=[3,2,3]
Therefore, r=p .
In the second example, it is impossible.