Hello everyone!

I’d like you to invite for CodeChef March Cook-Off that will start at 21:30 IST of 19-th March 2017 (check your time zone here) and will last 2.5 hours.

I am the author of problems and editorials, while Errichto is the tester. There are also some other people who helped with translations and miscellaneous issues who I will fill in later.

There is no registration required, anybody with a CodeChef handle can participate. Top participants can win CodeChef laddus (details on the contest page).

You will be provided 5 problems. There's one problem that shows a style of problems I would like to see more in competitions. Let me know what your thoughts are after the contest.

Hope to see you all on the leaderboard!

Why there is no such type of blog on codechef discuss forum as there was for for the past 2 contests, but there is a blog here on codeforces.

Ok now there is an announcement.

remainder: the contest will start in less than 4 hours

exactly 03:28:41

Why is it so hard ? xD

so tough !!!! Even Nicky Minaj is finding it difficult :p :p

Isn't her name Nicki Minaj, with an i?

Yes I will change it next year XDXD :p:p

Why are we randomly extending the contest by 15min?

Errichto Why was i getting WA on correct solution for 3rd problem RAINBOW? Hope there's better testing next time :p

How to solve INCXOR? For n = 2, I was able to brute force that answer is 2

^{30}·(2^{31}-LSB(max) + 1) where LSB(max) = 2 power log2(maximum value). Is this extendable?You can use digit DP using the state (index, b_mask, xor_mask). index ranges from 30 to 0 (inclusive). b_mask and xor_mask are masks of size n-1. We assign the bits of b in levels, level 30 to level 0. The ith bit in b_mask is set if b[i] < b[i+1] using some previously assigned bits in indices [idx+1, 30]. For each level, just check all possibilities of assigning bits to that level in b[].

Code

Very sad story, I ranked 10 in Rest of World when the original timer ended. I was very happy that I can gain some more laddus and get a step closer to have the new cool prizes.

After eating my cup noodles and got back to my computer, I found that my rank dropped to 11. When I first noticed that the contest was extended by 15 miuntes, only 2 minutes left and nothing I could do.

Goodbye my laddus :(

"March Cook-Off 2017 has been made unrated." You are saved. :)

Whatever it is rated or not, my laddus are gone :\ (unless those ranked top 10 when original timer ended are also rewarded)

And personally, I would like this round to be rated as I am quite sure that my rating will increase :D

Anyway, it is still fair for the round to be unrated as I believe many contestants are affected due to the data issue.

Can someone tell me the intuition behind the formula given in the Yet Another Card Game Editorial

Also how to come up with above formulas ?

Can someone share his/her approach in detail ?

The intuition is that all strategies will lead to the same expected value. Intuitively, the cards are played randomly, and the moves you have are fixed, so there's nothing you can really do to "beat" the randomness there in this case.

We can get the final expected value by linearity of expectation. For a red token, it has probability r/(r+b) of getting matched with a red card. For a blue token, it has probability b/(r+b) of getting matched with a blue card. So, the final formula can be derived from an application of linearity of expectation.

I really can't understand when cards are getting discarded, how we are using p times r/(r+b). I read it on codechef too still can't understand. Please can you elaborate a bit.

`We can get the final expected value by linearity of expectation. For a red token, it has probability r/(r+b) of getting matched with a red card. For a blue token, it has probability b/(r+b) of getting matched with a blue card. So, the final formula can be derived from an application of linearity of expectation.`

Won't r and b change after every extraction of token?

The probablity that a card is matched with token of same color is not dependent on any one case. It's calculated as follows. Let us denote tokens by

T_{1},T_{2}...T_{r + b}where tokensT_{1}toT_{r}are red andT_{r + 1}toT_{r + b}are blue tokens. Now for a tokenT_{i}where 1 ≤i≤r, we have to find the probablity that it's matched with a red card. If we consider all possible ways to pick the cards, it will be , let us denote it byx. Now lets fix at any 1 ≤i≤ra red card which means that ati^{th}turn we'll pick a red card. Considering this the total number of cases wheni^{th}turn will be a red card are , let us denote it byy. Now obviously, the probablity thati^{th}card is a red card is which you can simplify is nothing but and since we have proven it for a general 1 ≤i≤r. The expectation is therefore . You can prove similarly for blue cards too.First, let us denote random variable

X= Total Score at the end of all the turns. NowX= whereX_{i}denotes whether the token ati^{th}turn matched with a card or not. Now since expectation value follows linearity, therefore we can applyE(X) = . So, how to calculateE(X_{i})? We know that it doesn't matter in this thatX_{i}is dependent onX_{j}or not. So we can simply writeE(X_{i}) as . Now, to sum over allX_{i}, we can see that first term will only appear when forpred tokens and second term will appear forr+b-pblue tokens, hence the sum over allX_{i}'sis .Alternatively use a greedy approach. At each step,take the token of that color which has more coins. After taking that token,reduce the expected no of red and blue coins with probability of getting that coin.

I am sorry for invalid tests (c[i][j] = 0) in RAINBOW and thus extending the contest. We made some change in constraints there one day before the contest and I didn't modify my validator (program with asserts) — I will try not to let it happen again. And thanks for nice problems, lewin!

If you think problems were hard, I encourage you to upsolve them. Upsolving is even more valuable for you skills than participating in contests itself.

Can someone formally prove the correctness of the solution for Yet Another Card Game.

Editorial Link

I am still not getting the intuition that why should every strategy be optimal?

If at every move , if we take only red token ,then expected points are equal to

N.If at every move , if we take only blue token ,then expected points are also equal to

N.This means , at any move, we can either chose red token or blue token.

So is it unrated or when is rating going to be updated?

"March Cook-Off 2017 has been made unrated."

Has anyone received their laddus points?

It takes time for rating updates on CodeChef. For example, ratings for March long challenge which ended on 13th March have not been updated yet. So, laddu points are given only after rating update.