Hi!

I am thrilled to invite you to participate in CodeChef’s October Cook-Off, this Sunday, October $$$18$$$, from 9:30 pm to 12:00 am IST.

Followings are the basic information:

- Participants in each division will be given $$$6$$$ problems and $$$2.5$$$ hours to solve them.
- All problems have been cooked by me.
- Statements are very short unlike this announcement!
- Problems will have strong samples.
- There will be an interactive problem in this round, so, you should know how to deal with them.
- I hope your internet connection is good as some of the problems will feature awesome animations that I have created using Manim! Yeah, it means the problems will have better explanations.
- In my last contest, only $$$103$$$ div2 participants managed to solve div2C which is not good at all. So this time I have tried to maintain a more balanced difficulty distribution.
- I would like to thank teja349 for his brilliant coordination of this round.
- amnesiac_dusk tasted the problems(I hope they taste sweet!). I want to thank him particularly for helping me with the preparation of a few problems.
- Psychik is in charge of the editorials.
- Needless to say, Xellos did the statement improvements.
- Video Editorialists: Chirayu, agarwal19,darshancool25, manijuana, divesh2201
- Translators: Fedosik [Russian], Team VNOI [Vietnamese], solaimanope [Bengali], devils_code [Hindi], UoA_ZQC [Mandarin]

**Prizes:** The top $$$10$$$ Indian and top $$$10$$$ Global participants will receive CodeChef laddus, with which the winners can claim cool CodeChef goodies. Know more here.

The video editorials of the problems will be available on our YouTube channel as soon as the contest ends. Subscribe to get notifications about our new editorials.

Also, if you have some original and engaging problem ideas, and you’re interested in them being used in CodeChef's contests, you can share them here.

Good luck!

Clashing with CF Round 676

The blog has been revised, and I look like a fool...

Can't they postpone the round to 19th?

They should...

Please postpone the contest if possible.

Trust me I am the one who is more concerned about the clash. I have already discussed it with the CodeChef authority but here is the reason they stated explicitly:

It's because we've been having these contests at the same slot for many years, and that predictability is pretty important for the platform. We then wrote to MikeMirzayanov explaining the situation and we are hoping that he'll get back with some good news. He usually takes time to reply to emails, so fingers crossed! That said, in the worst case, we would be having clashing contestsUPD: MikeMirzayanov has just replied to the email and the div2 contest has been rescheduled. We, as a community, are thanking the CF authority for showing such a great gesture. Hopefully, now you can participate in both contests and enjoy the beauty of them.

CF round is rescheduled, now we can participate in both CC and CF, Thank you Mike

finally we can participate in both contest. thank you so much MikeMirzayanov.

Auto comment: topic has been updated by YouKn0wWho (previous revision, new revision, compare).some of the problems will feature awesome animations that I have createdThis is probably the first time a

problem statementwill have animations to help with the explanation. What a time to be alive!1427C - The Hard Work of Paparazzi

I think he meant in codechef. Btw, isn't it easy to upload gif in problem statement?

Auto comment: topic has been updated by YouKn0wWho (previous revision, new revision, compare).Are problems sorted by expected difficulty?

codechef*

CodeChef_admin, I would still like to know if problems are sorted by difficulty at the very beginning. And is it same for Longs and Lunchtimes too?

At CodeChef, problems are not supposed to be in sorted order. But in this contest, the problems were in sorted order because I like it in this way (Yes, INVERACTIVE was supposed to be easier than XOXO).

I didn't see your comment before the round, so couldn't reply to your comment :'(

The video editorials to the problems are uploaded on Youtube

Two hardest div1 problems aren't there yet. Is there a written editorial somewhere?

MORPH21

PERFSQRS

How to solve C? Great contest though :)

First, root the tree arbitrarily and calculate for each node its depth. Then, for each node, if its depth is even put a 1 on it. Else, put a 2. I dont have a rigurous proof of why this works, but it's easy to convince yourself once you see it.

Just Color the Nodes with 1 if their parent is 2 other wise 1

$$$1-2$$$ coloring should work.

Thank you for participating! What is your favourite problem from the contest?

Sir , Editorial published ? or how to solve D ?

Editorials have been published.

I liked

An Inveractive Problemthe most. Though couldn't solve it even after a lot of submissions.I particularly enjoyed solving PATHSUMS, though I didn't fully solve it (mistake in implementation), but all three problems I managed to come up with ideas for seemed very well balanced and interesting. Great round overall, at least for me.

Screencast with commentary, 2nd place: https://youtu.be/bDoHVOZlqCE

Every problem was nice separately (I especially liked PATHSUMS, INVERACT, MORPH) but there was too much constructive stuff. Div1 was: construct tree, construct sequence, construct sequence, discover sequence, transform sequence, unsolvable problem. The third of these (XOXO) quickly becomes dp problem but everything else was constructive/adhoc, that's just too much.

I understand now why antontrygubO_o enjoyed your previous cook-off :D

I enjoyed this one too a lot, just was too bad. But amazing round!

How is the checker implemented for DIANE?

CheckerThanks.

Can you describe the part of not calculating all gcds and minimum for every subarray naively and getting the accurate answer code seems wonderful but I just need to know the trick used here as it seems a wonderful thing to learn.

Sum of all subarray minimums:smash me

Sum of all subarray gcds:For each $$$d$$$ from $$$1$$$ to $$$M = 10^5$$$, find the number of subarrays divisible by $$$d$$$ and use a sieve-like algo to get the number of subarrays with each gcd. Complexity will be $$$O(M log\, M)$$$. To find the number of subarrays divisible by $$$d$$$, fix a $$$d$$$, then find the non-intersecting ranges $$$(l_1, r_1), (l_2, r_2), \ldots$$$ s.t. each element in that range is divisible by $$$d$$$ and then compute $$$\sum{\frac{(r_i - l_i + 1)(r_i - l_i + 2)}{2}}$$$.

For this specific problem almost all of the solutions are smth like $$$b + 1, b + 2, 1, c + 1, c + 2, 1, \dots$$$. One property of this array is that every subarray with length greater than $$$1$$$ has gcd $$$1$$$. So I have initially checked if the array has this property or not; if it has, then it would be faster to compute the sum of the gcds which is $$$= \frac{N(N-1)}{2} + \sum_{i = 1}^{N}{A_i}$$$

Can you please tell why we are including 1 for every substring like p+2,p+1,1 as p+2,p+1 is also giving same answer YouKn0wWho

Thank you very much !

Can anyone find me a corner case for my solution for problem DIANE?

For D=2*10^5-1 the size of your sequence will be 10^5+3 which exceeds the given size limit.

Did not receive laddus yet :(

Received them :P