Tournament Champion

Medium · rating 1450 · Simulation, Sorting

Teams 0..n-1 play a set of matches; the winner earns 3 points. The first line has n and m. Each of the next m lines has a b, meaning team a beat team b. Print the index of the champion (most points; ties broken by smaller index).

Constraints: 1 ≤ n ≤ 105

Related problems

Open Tournament Champion in Code Arena →