First of all, I'll be upfront with this: I do not know how to get $$$100$$$ points. During the contest I got $$$91.6$$$ points, and that's all I have a solution for (well, that's a lie, I know some improvements, though I haven't submitted them so I don't know how many points they get). Still, it's the highest score anyone got (well, that's also a lie, on Kilonova there is a $$$100$$$ point submission, probably from the organizers, though I don't understand what the code does... Also, hey, this is a solution I found in-contest, so the ideas are hopefully easier to guess), and RMI itself does not seem like they'll publish an editorial anytime soon, so here we are.
You can find the problem statement (and an online judge) on Kilonova.
This is an interesting communication problem that is 3-way (there are $$$3$$$ parties involved) instead of the usual $$$2$$$. You can refer to the URL for the full statement and limits.
Sending Binary Data
When I read this problem, the first thing that came to my mind was that trying to communicate in any way other than encoding the data into binary, transmitting those bits, and then decoding it seemed wasteful. So the first step is building an efficient way to communicate binary data (afterward, the problem reduces to an encoding/decoding problem).
My idea is to let every dish represent a $$$B$$$-bit value. With some luck, we can communicate $$$B$$$ bits at a time, and keep a backup protocol for when we don't have the target number:
- If I like a dish labeled with the target $$$B$$$-bit value, I order that dish.
- Otherwise, I skip ordering, and on the next turn whoever is ordering communicates a single bit (skipping for
0, ordering anything for1).
This protocol is not the most efficient at all, it is quite wasteful and is one of the main points for improvement. For example, you can start with this protocol, and for the backup, instead of falling back to a single bit via order/skip, use the information you have already sent to communicate more bits at a time (and later on, drop the randomized assignment altogether in favor of purely using previously sent information).
To randomly assign $$$B$$$-bit values to dishes, I use the following:
mt19937_64 rng(23); // set your favorite number as seed
// it has to be constant so every party has the same random data
for (int i = 0; i < n; i++) arr[i] = (i & ((1 << B) - 1));
shuffle(arr.begin(), arr.end(), rng);
Probability of Having the Target $$$B$$$-bit Value
Let $$$M_v$$$ be the number of dishes assigned the target value $$$v \in {0, 1, \dots, 2^B - 1}$$$ before shuffling:
Since the array is shuffled uniformly at random, a player who likes $$$K$$$ out of $$$N$$$ dishes effectively chooses a uniformly random subset of size $$$K$$$. The probability of having at least one liked dish with label $$$v$$$ is:
Expected Bits per Turn
Let $$$p = P(\text{hit})$$$. On a turn where the active player tries to send $$$B$$$ bits:
- With probability $$$p$$$, they send $$$B$$$ bits in $$$1$$$ turn.
- With probability $$$1 - p$$$, they skip ($$$1$$$ turn) and fall back to sending $$$1$$$ bit on the next turn ($$$1$$$ more turn, so $$$2$$$ turns total for $$$1$$$ bit).
Thus, the expected number of bits sent per turn is:
What this all means is simply that the optimal value of $$$B$$$ is around $$$log_2(K)$$$ (Substract 1, 2, idk. Or just use desmos). you'd probably want to submit for every value of $$$B$$$ from like $$$8$$$ to $$$16$$$. (Hey, I haven't said it's a neat solution, I just said it's a solution you can find during a contest.)
Encoding the Data
Anyways, now we can send bits. How do we encode the data?
For the last $$$2$$$–$$$3$$$ subtasks, we simply send the raw bitmask (for each $$$i$$$, 0 if Acid likes $$$i$$$ or 1 if Base likes it, or vice versa). This is a very simple encoding that obviously uses $$$N$$$ bits.
For any other subtask, we have to find an actually decent encoding. The first observation is that the array is sparse ($$$K$$$ is much smaller than $$$N$$$), so sending the distances (gaps) between consecutive elements of the smaller array instead of sending the array itself is much more compact. The second observation is that these distances have a bounded sum, they can sum to at most $$$N$$$.
There is apparently a well-known way to do this already, called Golomb-Rice coding, though I did not know about it during the contest, so that's not what I used. However, what I came up with ends up being not that far behind Golomb-Rice in efficiency.
My idea was that in an array whose sum is bounded, values are much more likely to have a smaller bit-length, so what we care about most is efficiently sending small numbers. To do this, I send each number in chunks of $$$W$$$ bits:
- For a given number, send its lowest $$$W$$$ bits, followed by $$$1$$$ continuation bit indicating whether the number has ended (
0if finished,1if more chunks follow). - If the number ended, reconstruct it from the collected $$$W$$$-bit chunks, clear the buffer, and move on to the next number; otherwise, keep reading chunks.
To indicate the end of the transmission, we can either append a sentinel value larger than any valid gap (such as $$$N + 1$$$) at the end, or send the total bit count at the start of the communication.
Bit Cost Analysis of the Chunk Encoding
Suppose we have $$$K$$$ gaps $$$d_1, d_2, \dots, d_K \ge 1$$$ satisfying $$$\sum_{i=1}^K d_i \le N$$$.
A positive integer $$$d$$$ requires $$$\lfloor \log_2 d \rfloor + 1$$$ bits in binary, so splitting it into $$$W$$$-bit chunks takes:
Since each chunk costs $$$W + 1$$$ bits ($$$W$$$ data bits + $$$1$$$ continuation bit), the total number of bits used to encode all $$$K$$$ gaps (plus $$$1$$$ sentinel value) is:
Worst-Case & Average-Case Bound
Because $$$\log_2(x)$$$ is concave, by Jensen's inequality the sum $$$\sum_{i=1}^K \log_2 d_i$$$ is maximized when all gaps are roughly equal, i.e., $$$d_i \approx \frac{N}{K}$$$.
Plugging $$$d_i = \frac{N}{K}$$$ in, each gap takes approximately $$$\frac{\log_2(N / K)}{W}$$$ chunks (rounded up), giving an upper bound of roughly:
Anyways, with the test cases of the problem, the values of $$$W$$$ that improve your score are $$$1$$$ and $$$2$$$. I have submitted $$$3$$$ and $$$4$$$ but those did not improve my points, and I did not submit any larger value because of that.








