Editorial for DMOPC '22 Contest 2 P1 - DMOPC Crisis


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: 4fecta

Subtask 1

This subtask was created to reward experimenting with constructing small solutions by hand.

Time Complexity: \mathcal{O}(N)

Subtask 2

Intuitively, the fact that at least one of each member's neighbours must leave means that there cannot be more than N/2 members who remain (this can be proven rigorously by the pigeonhole principle, try it out!). Then, after experimenting with small patterns as motivated by the previous subtask, one may discover that the repeating sequence __MM__MM__MM... is one which satisfies the constraints and provides approximately N/2 remaining members, which leads to the full solution.

Time Complexity: \mathcal{O}(N)


Comments

There are no comments at the moment.