CF1876C.Autosynthesis

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Chaneka writes down an array aa of nn 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 rr consisting of all uncircled elements of aa following the order of their indices.

Chaneka also makes another sequence pp such that its length is equal to the number of operations performed and pip_i is the index of the element that is circled in the ii -th operation.

Chaneka wants to do several operations such that sequence rr is equal to sequence pp . 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 nn ( 1n21051 \leq n \leq 2\cdot10^5 ) — the size of array aa .

The second line contains nn integers a1,a2,a3,,ana_1,a_2,a_3,\ldots,a_n ( 1ain1\leq a_i\leq n ).

输出格式

A single line containing 1-1 if it is impossible.

Otherwise, the output consists of two lines. The first line contains an integer zz representing the number of operations performed. The second line contains zz integers, the ii -th integer represents the index of the element circled in the ii -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 a2a_2 gets circled 11 time.
  • Element a3a_3 gets circled 22 times.
  • The uncircled elements (ordered by their indices) are a1a_1 , a4a_4 , and a5a_5 . So r=[3,2,3]r=[3,2,3] .
  • p=[3,2,3]p=[3,2,3]

Therefore, r=pr=p .

In the second example, it is impossible.

首页