10194-football (aka soccer)
Time limit:3.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=98&page=show_problem &problem=1135
The Problem
Football the most popular sport in the world (Americans insist to call it "soccer", but we'll call it "Football"). As everyone knows, Brasil is the country of this have most world Cup titles (four of Them:1958, 1962, 1970 and 1994). As our national tournament have many teams (and even regional, tournaments have many teams also) it's a very hard task to K EEP track of standings with so many teams and games played!
So, your task are quite simple:write a program that receives the tournament name, team names and games played and outputs The tournament standings so far.
A team wins a game if it scores the goals than its oponent. Obviously, a team loses a game if it scores less goals. When both teams score the same number of goals, we call it a tie. Team A is earns 3 points for each win, the 1 point for each tie and the 0 point for each loss.
Teams are ranked according to these rules:
Most points earned.
Most wins.
Most goal difference (i.e. goals scored-goals against)
Most goals scored.
Less games played.
Lexicographic order.
The Input
The ' I ' input ' would be ' an integer N in a line alone (0 < N < 1000). Then, would follow N tournament descriptions. Each one is begins with the tournament name and on a single line. Tournament names can have any letter, digits, spaces etc. Tournament names would have length of at most 100. Then, in the next line, there'll be a number T (1 < T <=), which stands for the number of teams participating O n this tournament. Then'll follow T lines, each one containing one team name. Team names could have any character this have ASCII code greater than or equal to (spaces), except for ' # ' and ' @ ' Charact ERS, which'll never appear in the team names. No team name would have more than characters.
Following to team names, there'll be is a non-negative integer G on "a single" which stands for the number of games Alre Ady played on this tournament. G'll be no greater than 1000. Then, G lines would follow with the results of games played. They'll follow this format:
Team_name_1#goals1@goals2#team_name_2
For instance, the following line:
Team A#3@1#team B
Means. A game between Team A and Team B, team a scored 3 goals and Team B scored 1. All goals would be non-negative integers less than 20. You could assume that there won't be inexistent team names (i.e. all team names this appear on game results'll have app Eread on "team names" and "no team" play against itself.
The Output
For each tournament, you must output the tournament name in a single line. In the next T lines your must output the standings, according to the rules above. Notice that should the Tie-breaker is the lexographic order, it must is done case insenstive. The output format is shown bellow:
[A]) team_name [B]p, [C]g ([d]-[e]-[f]), [G]GD ([H]-[i])
Where:
[A] = Team rank
[b] = total points earned
[C] = games played
[d] = Wins
[E] = Ties
[F] = Losses
[g] = goal difference
[h] = goals scored
[I] = Goals against
There must is a single blank spaces between fields and a single blank line between output sets. The sample output for examples.
Sample Input
2 World
Cup 1998-group A
4
Brazil
Norway
Morocco
Scotland
6
Brazil#2@1#scotland
Norway#2@2#morocco
Scotland#1@1#norway
Brazil#3@0#morocco
morocco#3@0#scotland
brazil#1@2#norway
Some Strange Tournament 5 Team, Team B, Team C, Team
D, E 5 team,
a#1@1#team B
Team A#2@2#team C Team
a#0@0#team D team
e#2@1#team C team
E#1@2#team D
Sample Output
World Cup 1998-group A
1 Brazil 6p, 3g (2-0-1), 3GD (6-3)
2) Norway 5p, 3g (1-2-0), 1GD (5-4)
3) Morocco 4p, 3g (1-1-1), 0GD (5-5)
4) Scotland 1p, 3g (0-1-2), -4GD (2-6)
Some Strange Tournament
1) Team D 4p, 2g (1-1-0), 1GD (2-1)
2 team E 3p, 2g (1-0-1), 0GD (3-3)
3) Team A 3p, 3g (0-3-0), 0GD (3-3)
4) Team B 1p, 1g (0-1-0), 0GD (1-1)
5) Team C 1p, 2g (0-1-1), -1GD (3-4)
No brain simulations.