Editorial for COCI '19 Contest 1 #1 Trol
Submitting an official solution before solving the problem yourself is a bannable offence.
At first, this task might seem a bit frightening (for the first task) since it requires you to solve a bunch of queries with very large constraints and Marin's changes on the array elements seem relatively complex. Since this is the first problem called trol, you might suspect that an elegant solution is hiding somewhere.
But, let's start from the beginning. In the test data worth a total of
For an additional
In order to obtain full score on this problem, you needed to make a certain observation. This observation could be made in two ways which we will depict by sharing a couple of truthful anecdotes that occurred during the making of this round.
First way
The task author first told this problem to Marin. Marin is an experienced competitive programmer and he knows that the suggestion for the easiest COCI problem must not be too difficult. Therefore, he conjectured that something fishy must be going on with the array after changes. In a matter of minutes, he implemented the aforementioned solution (worth
Marin didn't fully understand why is that the case, but he experimentally proved shown that his conjecture holds.
Second way
The task author then spoke to Stjepan. Stjepan really did recently receive his maths degree so it wasn't long before he remembered something he learned way back in primary school: "The number is divisible by
Whether your thought process follows Marin or Stjepan, one thing is certain, once you made this observation the task became easy. Suppose we divide the numbers from the query in consecutive blocks of size
Comments