Editorial for COCI '22 Contest 3 #2 Dirigent
Submitting an official solution before solving the problem yourself is a bannable offence.
For the first subtask, we can try breaking the circle at each position and then check whether it results in a sorted sequence. The complexity of such an approach is
For the second subtask, we can see that it is sufficient to try and break the circle at a position which will result in
For all points, let us focus on neighbours (all pairs of students that are holding hands). There are also
Observe that the condition from the task holds if and only if there is exactly
After each swap, at most
Comments