#C11766. Ping Pong Tournament Results
Ping Pong Tournament Results
Ping Pong Tournament Results
In a ping pong tournament, there are \(M\) players and a series of matches. Each match is described by three integers: the winner's ID, the loser's ID, and the number of games the winner won in that match. The tournament winner is defined as the winner of the last match played. Your task is to compute the total number of games played and determine the tournament winner's ID.
If no matches are played, then the total number of games should be considered \(0\) and the tournament winner is \(\text{None}\).
The total number of games can be computed as \(\sum_{i=1}^{N} g_i\) where \(g_i\) is the number of games in the \(i\)-th match, and if \(N > 0\) then the winner is the winner \(w_N\) of the last match.
inputFormat
The input is given via standard input (stdin). The first line contains an integer \(M\) which represents the number of players. The second line contains an integer \(N\) representing the number of matches played. This is followed by \(N\) lines, each containing three space-separated integers: the winner's ID, the loser's ID, and the number of games won by the winner in that match.
outputFormat
Print two space-separated values to standard output (stdout): the total number of games played and the tournament winner's ID. If no matches are played, output 0 None
(with the word None printed as a literal string).
4
3
1 2 2
1 3 2
4 1 2
6 4