Editorial for DMOPC '20 Contest 2 P2 - Lousy Christmas Presents
                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.
                Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1
For every query, iterate through all the colours and find the first occurrence of  and the last occurrence of 
.
The answer is given by .
Time complexity: 
Subtask 2
There is no intended solution. (Red herring task.)
Time complexity: 
Subtask 3
Keep track of the first and last occurrence of every colour. For every query, it's now possible to query  and 
 in 
. The rest of the solution follows from Subtask 1.
Time complexity: 
Comments