Unofficial editorial December long challenge

output of
1

3 4

RRGG
RGRG
GGRR

output -

GRGR

RGRG

GRGR

According to me must be 8 (5+3)
but all top solution is 16

EXPLANATION -

In fist row ,replace first R by last G gives 5

then In third row ,replace second G by third R gives 3,
Hence 5+3=8

I DONT UNDERSTAND WHY ?

@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?

1 Like

@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

@taran_1407 i have implemented vk18 as stated but i am getting WA for 2 and 3 test case

link to My solution:-CodeChef: Practical coding for everyone

I tried doing a similar approach but don’t understand where I went wrong. Can you help?
The link is https://www.codechef.com/viewsolution/16530358

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.

For CHEFEXQ: Chef and easy XOR Queries, i wrote a blog post which can help you guys understand square root decomposition. Blog post link.

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.

Here is link to my solution CodeChef: Practical coding for everyone.

Can you explain why you used the condition ((i + j)&1 == 1) in GIT01

For pre-processing you will need to declare array of size V[2000000], but my compiler (C++11) gives segmentation fault. How to solve this issue?

This is my solution for CPLAY. CodeChef: Practical coding for everyone Can someone check and tell me why its giving Wrong Answer?

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!

1 Like

@taran_1407 can u please check this code CodeChef: Practical coding for everyone
FOR GIT01

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).

Cheers!! Happy Coding…

Well, I’m glad that we are not in for plagiarism accusation then… :smiley:

3 Likes

Hey, I have run the code and it gives 8 as output. Check it here: 2oXGt7 - Online Java Compiler & Debugging Tool - Ideone.com .

[Note: I have used @taran_1407 's code.]

All top solution??

Can you please mention that solution link, which gives 16 as answer.

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. :slight_smile: