#K48417. Team Win Counter
Team Win Counter
Team Win Counter
In a tournament, teams play matches where each match is represented by a pair of team names: the winning team and the losing team. Your task is to calculate the number of wins for each team and then display the results in lexicographical order of team names.
Formally, you are given an integer ( n ) representing the number of matches. Each of the following ( n ) lines contains two strings: the winner and the loser of that match. You must calculate the win count for every team and output each team along with its win count sorted in increasing lexicographical order based on the team names.
For example, if the input matches are:
5 TeamA TeamB TeamC TeamD TeamA TeamC TeamD TeamB TeamC TeamA
The output will be:
TeamA 2 TeamB 0 TeamC 2 TeamD 1
This problem requires careful processing of input and sorting of team names before output. The solution should read from standard input and write to standard output.
inputFormat
The first line of input is an integer ( n ) representing the number of matches. Each of the following ( n ) lines contains two space-separated strings indicating the winner and the loser of a match.
outputFormat
For each team that appears in the input, output a line containing the team name and its win count separated by a space. The teams should be printed in lexicographical order.## sample
1
TeamA TeamB
TeamA 1
TeamB 0
</p>