After days of suffering, I am finally able to solve JOISC 2025 Fortune Telling 3. I find this problem very interesting, so I decided to write a blog to share the solutions. The following records my thought processes to the problem.
Directly send all cards to Bruno. Count the number of ones among the sent cards.
We should think about the binary system. For the first 891 bits, we will send 10 ‘0’s to the left and 10 ‘1’s to the right. So the sequence after the first 891 bits should look something like this: 00000000001111111111. For the last 9 bits, just directly send the binary representation of the number of ‘1’s, by inserting the corresponding bits into the correct ‘slots’. Add up the binary representation of the number of ‘1’s and the number of ‘1’s in the last 9 bits will give you the final answer.
What if there are less than 10 ‘0’s or less than 10 ‘1’s? Just append all the 9 bits in the back of the sequence. By determining the length of the sequence, you will be able to identify whether there is insufficient ‘0’s or ‘1’s.
The solution will give you $$$L = 29$$$. Unfortunately, I didn't implement this solution.
We should go away from the binary system. The problem that goes with a binary system is that it has an extremely high setup cost, you need to send 10 ‘0’s and 10 ‘1’s. We want a lower setup cost. In the 71-point solution, what we need to do is the send a 4 ‘0’s and 4 ‘1’s setup, then by sending 10 extra bits, we can send a total of (10+4)C4 = 1001 different types of information, and that will be enough to pass 71 points with $$$L = 18$$$
If there are less than 4 ‘0’s or less than 4 ‘1’s, just deal it as the way stated in the 51-point solution.
The 81-point solution is similar to the 71-point solution, just with a little bit of changes. We want to set up another way to deal with the “Less than 4 ‘0’s or less than 4 ‘1’s” case. So we can send more information based on the length of the sequence.
The way to deal with less than 4 ‘0’s or less than 4 ‘1’s is as follows: If there are less than 4 ‘0’s, then for the remaining bits, we will just send the ‘1’s that appeared. We will be able to identify whether a sequence has an insufficient amount of ‘0’s by counting the number of ‘0’s in the sent sequence. Similarly, we can also do the same for ‘1’s.
So, now the length of the sequence can also be a way of transmitting information. We can send a total of (4+1)C4 + (4+2)C4 + … + (4+8)C4 = 1286 different types of information by sending 8 extra bits, and we can get 81 points by having $$$L = 16$$$.
Dynamic systeming.
Well, up till this part, we have already done a lot of different types of optimizations. Including the system, as well as how to deal with some corner cases. It seems that none can be done to further optimize the solution.
In fact, we have to optimize the system.
In previous systems, we always have a fixed system (In the binary solution, we always have 10 ‘0’s and 10 ‘1’s. In the 71 and 81-point solutions, we always have 4 ‘0’s and 4 ‘1’s in the system).
In the 100-point solution, what I use is a dynamic system. In this system, for the first 891 bits, I still send 4 ‘0’s as part of the system, but the number of ‘1’s will be dynamically adjusted. In my code, I will add ‘1’s at the 1st ,31st,165th and 463th ‘1’, based on some nCr calculations done offline.
By doing this, we can get ((4+1)C4+...+(4+6)C4) + ((3+1)C3+...+(3+7)C3) + ((2+1)C2+...+(2+8)C2) + ((1+1)C1+...+(1+9)C1) = 1008 different types of information. However, in reality, my code can only send 893 different types of information, because we need to account for cases where you can no longer send the information when adjusting to the respective mode. But 893 different types of information is just enough to pass $$$N = 900$$$!!!
And so the problem has been solved in $$$L = 14$$$. Yay.
I am not sure whether the official solution shares the same idea with my solution, but regardless, I still think that this problem is really great, as always for JOI competitions.
This is my first time writing a solution blog, so if there are any parts or bits that seem unclear to you, feel free to point it out :)








