#P4650. [COCI 2017/2018 #5] Karte
[COCI 2017/2018 #5] Karte
Description
There are cards stacked together. On the -th card, there is a number , meaning that at least cards below it have incorrect information. If there are indeed at least cards below it with incorrect information, then the information on this card is correct; otherwise, the information on this card is incorrect. (We consider that below the bottom card there are incorrect cards.)
Now you need to rearrange the order of the cards so that exactly cards have incorrect information.
Input Format
The first line contains two positive integers and , representing the number of cards and the required number of incorrect pieces of information.
The next lines each contain one number, representing the corresponding .
Output Format
If no rearrangement exists, output . Otherwise, output the of the cards from top to bottom. If there are multiple solutions, output any one.
4 2
1 2 2 3
2 3 1 2
5 3
2 1 3 0 3
3 3 0 1 2
6 4
0 2 5 2 0 1
-1
Hint
For of the testdata, .
For another of the testdata, .
Explanation of Sample 2:
The -th card shows , but there are only incorrect cards below it, so it is incorrect.
The -th card shows . There is incorrect card below it (the -th), so it is correct.
The -th card shows . There is incorrect card below it (the -th), so it is correct.
The -th card shows , but there is only incorrect card below it (the -th), so it is incorrect.
The -st card shows , but there are only incorrect cards below it (the -th and the -nd), so it is incorrect.
Therefore, there are incorrect cards in total.
Translated by ChatGPT 5
京公网安备 11011102002149号