Editorial for DMOPC '17 Contest 5 P2 - Mimi and Binary
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:
For the first subtask, it suffices to iterate through the suffix and return the first index where there are occurrences of .
Time Complexity:
For the second subtask, we can preprocess the array by keeping 2 dynamic arrays, one for zeroes and one for ones, as a second array which holds the index of the index in each of these dynamic arrays. A query can thus be answered in time by retrieving the index of the left endpoint from the array, and adding , and then finding this index in the dynamic array.
Time Complexity:
Comments