ICPC World Finals 2025
Solved by 135 teams.
First solved after 23 minutes.
Shortest judge solution: 501 bytes.
Maybe somewhat counterintuitively, it is helpful to first make all the wheels show distinct symbols. This can be achieved by going through the wheels one by one and for each wheel trying all of its positions and leaving it in the position that maximizes the number of distinct visible symbols. The next step is to find out the relative order of the wheels. To this end, go over all pairs of wheels and rotate one wheel one position forward and the other wheel one position backward. If this results in all n symbols being visible again, then the second wheel must be one position further than the first. Finally, once the full ordering of wheels has been found, they can be set to show the same symbol using just n − 1 additional queries. The total number of queries using this approach is around 3n2, which easily fits the query limit.
While most teams and most judges used some variation of the approach above, different solutions exist. For instance, as a wheel is rotated through all of its positions (while keeping the other wheels fixed), there exists some k such that the number of distinct visible symbols is always either k or k + 1, depending on whether the wheel coincides with some other wheel or not. This results in a bitstring describing the given wheel, and the relative positions of the wheels can be pieced together based on the bitstrings for all the wheels. If one leverages randomization, this can even lead to solutions that make do with a subquadratic number of queries.