Editorial for SAC '22 Code Challenge 2 P5 - Even Colouring
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
It suffices to maintain an array with each value and loop the range
Time Complexity:
Subtask 2
Maintain two Fenwick Trees (or Segment Trees) for the two parities (i.e., whether the index is even or odd).
If the left bound of the query is on an even index, query the even index Fenwick Tree from
Time Complexity:
Note that this problem is very similar to this Codeforces educational problem with some slight modifications.
Comments