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

View as PDF

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

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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

• commented on Dec. 14, 2019, 1:45 p.m.

My code seems to be running O(N). Why is it still tle?

• 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?

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

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

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

Thanks for the feedback :)