We invite you to participate in CodeChef’s June Lunchtime, this Saturday, 26th June, from 7:30 PM — 10:30 PM IST.

There will be **7 problems in Division 3 and 6 problems in Division 1/2**.

Joining us on the problem setting panel are:

Contest Admins: Ashish Ashishgup Gupta and Jatin jtnydv25 Yadav

Head Admin: Alex Um_nik Danilyuk

Tester: Felipe fmota Mota

Setters: Daanish Mahajan, Jatin jtnydv25 Yadav, Bharat Singla, Lakshay lakshyaj21 Jain, Divyam divyamsingal01 Singal, Ritika kairakal Gupta, Nishan _Ape_ Singh, Pranav ExplodingFreeze Rajagopalan

Statement Verifier: Riley 1-gon Borgard

Editorialist: Aman _cherry_ Dwivedi

Video Editorialists: Chirayu Chirayu Jain, Prachi agarwal19 Agarwal, Darshan darshancool25 Lokhande, Yashodhan Molotov Agnihotri, Shivam Bohra, Aryan Agarwala, Meet mithh_gemphir Singh Gambhir, Rajarshi RestingRajarshi Basu

Mandarin Translator: Huang Ying

Russian Translator: Fedor Fedosik Korobeinikov

Bengali Translator: Sakib SakibAbrar Abrar

Vietnamese Translator: Team VNOI

**Problem Submission:** If you have original problem ideas, and you’re interested in them being used in CodeChef's contests, you can share them here.

**Prizes:** Top 10 Indian and top 10 Global school students from ranklist will receive certificates and CodeChef laddus, with which they 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.

**Admin Note**: This Lunchtime has a **replay** of some of the problems used in IOITC Day 2/3 (Final Selection round of Indian IOI Team). Thanks to all the testers who tested the IOITC as well!

Good luck and have fun!

Reminder that contest starts in 90 minutes

aryanc, the dalal of Codeforces.

$$$\geqslant w \leqslant$$$

Thanks for the compliment.

As a participant of Indian TST, I feel the quality of problems is one of the highest compared to all other OIs this year.

Less than 2 minutes

Div3 and Div1 problems are interchanged. It should be fixed soon.

.

Hope you guys will do plag check this time :\

You are expecting too much from codechef!

Nice problemset.

Why is below code giving TLE verdict for "From rational to binary" problem ??

Spoiler~~~~~

~~~~~

Contest isn't over :)

Edit: Now that contest is over, endl $$$10^6$$$ times means the buffer being flushed $$$10^6$$$ times which is far too much for 1 second.

"The contest has been extended for all by 15 minutes due to the initial mistake in the div-1 and div-3 scorable vs non-scorable problems." wasn't contest was extended for all?? I am not able to sumbit, if not, please give more clear announcements next time

My last ~1.5 hours of the contest:

:( internal error occurred in the systemIf this was on an interactive problem, internal error = WA on Codechef usually.

How to do Node Marking ?

I first calculated $$$single[\cdot]$$$, where $$$single[p]$$$ denotes the least number of colorings needed to color exactly $$$p$$$ nodes in a

singletree (calculated using some DP on a tree). Then we calculate the total answer in a knapsack-like manner using those calculated values.Ah, I had a intuition that we need to do something knapsack-ish, but I was never close to even 10 % of solution.

Also, How to calculate single[p] ?

You can calculate it in one more knapsack-like DP on the tree -- try to construct the solution for the node given the solution for all its sons.

Do you mind posting your solution? The editorial doesn't make sense to me.

Editorials

I am surprised 1-gon isn't here to claim his daily dose of contribution yet.

The editorial for NDMRK can be explained in a better way, it is not quite understandable in its current state. It seems that the setter's solution has just been english-ified the dp recurrence of explaining the idea. The $$$DP[x][itr_1 + itr_2]$$$ part is not clear at all.

I calculated the DP in another way in problem NDMRK since I was scared the tree DP wouldn't be $$$O(N * K)$$$.

Run an euler tree and store the ranges that each node's subtree covers and sort these ranges by start point. Note that we have the special property that for any two ranges, one wholly covers the other or their intersection is empty.

Now let $$$dp[i][j]$$$ be the minimum number of ranges to select in the last $$$i$$$ ranges to color exactly $$$j$$$ nodes. Transitions here are extremely simple:

Set $$$dp[i][j]$$$ to the minimum of these two values. Since transitions are $$$O(1)$$$, this dp runs in $$$O(N * K)$$$. The rest of the solution proceeds as the editorial does. Here is my code.