@taran_1407 can you explain the third subtask where you added 2( sum[2i-1] - sum[i]) I understood adding of the first and the third term but why the above one?
@taran as a beginner i want to know how you compared the cake in GT101 with chess board ? i mean there is no word of chess board used in question ? i submitted around 5 to 7 solutions but WA . What made you thing it is a chess board ? again thanks in advance
Nicely explained!
I was stuck on the problem Total Diamonds [VK18]. I kept looking for patterns to develop a formula in order to establish my O(1) solution; apparently I was looking in the wrong direction altogether.
I wonder, but I have WA in VK18 and still can’t catch where are principial differ of my code and solution idea, except I has’t optimaze it.
I try different kinds of debug output, but cannot fix what’s wrong. Its seems correct, but WA appears anyway.
I was stuck on the Vk18 since 2 days, I had solved the question as you did in subtask-2, but I always wondered about finding a formula or pattern to get a O(1) solution for the 3rd subtask. So as a beginner is it always allowed to pre-process answer or only when there is no other way (how to find that there is no other way and you need to preprocess??)
btw thanks for the editorial!
I can’t believe but I used the exact same approaches for all the 3 problems and in 3rd question, I solved it subtask wise only, i.e. the same approaches explained for each subtask by you.
When you have 1e5 test cases to answer, you would find it really common to pre-process in such a way that we can answer our queries in O(1) or O(logN). Otherwise we’ll get TLE.
I just solved the problem for all values from 1 to 1e5, answering queries int O(1).
Well, the problem states that every red marble should only have green marbles in four adjacent cells. Yes, problem doesnt mention chess board, but as i identified the pattern, i saw it similar to chess board. Where a white cell always has four black adjacent cells and same for black cells.
I mentioned chess board to make myself entirely clear.