My first instinct was to try topological sort and I kept going down that path longer than I should have.
Model the match results as a directed graph where an edge from A to B means A beats B. The exact rank of a player is determined if and only if the number of players known to be stronger and the number known to be weaker sum to n-1. Use transitive closure (e.g., Floyd-Warshall) to compute all reachability, then for each player count stronger and weaker players.
Pro tip: Mention that this problem is equivalent to finding vertices with a unique position in the total order, and that the condition (stronger + weaker == n-1) is both necessary and sufficient. Also note that the graph is a DAG and transitive closure can be computed efficiently with bitsets for large n.
Create a directed graph where each player is a node, and a directed edge from u to v indicates that u beats v. This captures the known dominance relations.
Use Floyd-Warshall or bitset-based reachability to determine all pairs (u, v) such that u is known to be stronger than v (directly or indirectly).
For each player, count the number of players known to be stronger (incoming reachability) and weaker (outgoing reachability).
A player's exact rank is determined if and only if stronger + weaker == n - 1. The rank is then stronger + 1.
Gather the ranks of all such players and return them in any order (or sorted if required).
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.