## DMOPC '17 Contest 4 P4 - Cops and Robbers

View as PDF

Points: 7 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

In the beautiful capital of Dmojistan, there are banks and a single policeman. The banks are numbered from to . You managed to find the policeman's schedule for the next days. It turns out that on the day, he will be protecting bank .

Armed with this information, you are planning to rob all banks in the next days. You will rob bank on the day. A robbery will be successful if the cop is not protecting that bank on that day (that is, ).

Before you can start robbing, you need to determine a sequence which will work. Output a sequence which will rob all banks or if it is not possible to rob all banks. The sequence should be integers from to .

Any valid sequence will be accepted.

#### Input Specification

The first line will contain .
The next line will contain space-separated integers .

#### Output Specification

Output a valid sequence if it is possible or if it is not. The sequence should be integers from to .

#### Sample Input

5
2 1 1 1 1

#### Sample Output

1 2 3 4 5

• AlanCCCL2S18  commented on June 4, 2018, 11:25 a.m.

I don't know what's getting me tle on the second subtask. Any ideas as to why this is happening?

• wleung_bvg  commented on June 4, 2018, 12:52 p.m.

Your algorithm appears to be (due to ArrayDeque.contains()).

• AlanCCCL2S18  commented on June 4, 2018, 2:58 p.m.

Thanks for the feedback :)