TopCoder returned last week from another long break with SRM 852 (

problems,

results, top 5 on the left). The 1000-pointer was about counting

*k*-th roots of a specific permutation, and it took the winner SSRS_ just 3.5 minutes since they reused their

submission for a more general problem about counting

*k*-th roots of any permutation. More generally this problem did not present as much of a challenge for the top participants as the 500-pointer, which saw many solutions fail and therefore offered a lot of challenge opportunities. Of the three contestants who managed to solve everything, kotatsugame was behind after the coding phase but managed to recover to the second place thanks to 200 challenge points. Congratulations to all three on the great performance!

The 2nd Universal Cup. Stage 20: Ōokayama followed, as usual, on Saturday (

problems,

results, top 5 on the left,

analysis). 16 problems in a round is still a lot even by today's standards, but this still did not stop team HoMaMaOvO from solving all of them with 6 minutes to spare :) Well done! This is their 7th win of the season compared to 9 for USA1, and they are definitely still in contention for the

overall first place.

Finally, Codeforces Round 921 wrapped up the competitive week also on Saturday (

problems,

results, top 5 on the left,

analysis). Having dealt with the four easier problems in the first hour, I've decided to focus on

problem F since there it seemed that we just need to solve the

*n*=3 case and the rest will easily follow, while

problem E gave some generating function vibes :) Unfortunately even the

*n*=3 case in F turned out too hard for me. I have even implemented a brute force that tried different random strategies and it still could not solve

*n*=3. The reason for that was probably the fact that the strategies I tried were non-adaptive: they asked the same questions irrespective of the answers.

Implementing a brute force over adaptive strategies seemed harder, so I've decided to give E another chance. I've realized it feels difficult because the number of choices we have always changes, therefore we are multplying probabilities with different denominators and it's not clear how to do the summation over different trajectories nicely. But then I remembered I already had this feeling in the past, and writing about this in my blog :) So I tried searching for [divide by the sum site:blog.mitrichev.ch], and for some reason this search returned

what I was looking for on the first page. I've re-read that solution, and remembered the key trick: even if the overall number of choices is different every time, since all choices have the same probability at each step, the relative probability for a particular subset of choices of fixed size will always be the same. In the linked problem it was just 2 options each with probability 50%, while in problem E this time, if we focus on whether we visit a particular pair (

*x*,

*y*) or not, the number of choices affecting this outcome is always

*x*+

*y*, no matter the current state, so we can compute the probability of such visit happening very nicely.

There was still some work to do to improve the complexity from O(

*n*^{2}) to O(

*n**log

*n*), and luckily I managed to do it before the end of the round. This was of course still not enough to compete with jiangly and others who focused on problem E earlier. Congratulations on the win!

Thanks for reading, and check back next week.