Editorial for WC '16 Finals J1 - Fencing


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

For each cow i from 1 to N, we'll need to compute the number of matches m_i that they won. To do so, we can iterate over all cows j from 1 to N such that i \ne j, and increment m_i whenever S_{i,j} > S_{j,i}. Overall, we'll be looking for the cow i with the largest m_i value. To find that cow, we can keep track of the largest m_i value seen so far (as well as the value of its associated index i), and replace it whenever we come across a new maximum. At the end, we can output that associated cow index i.


Comments

There are no comments at the moment.