Czech ACM Student Chapter
Czech Technical University in Prague
Charles University in Prague
Technical University of Ostrava
Slovak University of Technology
Masaryk University
acm
cz
acm
cz
CTU Open Contest 2007
Soccer Tournament
soccer.c, soccer.C, soccer.p, soccer.java
ACM decided to run a big advertising campaign. Beside others, it will sponsor soccer tourna-
ments by providing them with a system for computing and displaying game results. You are to
write that system.
Input Specification
The input contains description of several tournaments. Each tournament begins with a line
containing single positive integer N: the number of participating teams, N . 80. Then there
are N lines, each containing a unique name of one team. The name is case-sensitive and may be
composed only from letters, digits, dots ("."), and dashes ("-"). No name will be longer than
100 characters.
After the team names, there will be a line with a single non-negative integer M:thenumberof
games that have already been played. Each of the next M lines describes one game and contains
the host team name, space, dash, space, guest team name, space, and the game result. The
result will always appear as a single digit (0-9), colon (":"), and another single digit (0-9). The
digits specify the number of goals scored by the host and guest teams.
Then, the next tournament is described. The last tournament is followed by a zero on a separate
line. No output should be produced for this zero.
You may assume that all team names have been listed among the N teams. All games will have
distinct opponent pairs. This also means that any two teams may play at most two games with
each other - in such a case, each of the two teams will be a host in one game and a guest in
the other.
Output Specification
For each tournament, output a line containing the word "RESULTS" and a colon (":"), then
a result table, empty line, a line with the word "STANDINGS" and a colon, a line with 10 dashes
("-"), then current standings, and another empty line.
The result table is "drawn" using dashes ("-"), pipes ("|"), and plus signs ("+"). The table
has N +1 rows andN + 1 columns. The upper left cell is always empty (filled with spaces).
Otherwise, the first column contains full team names, the width of the column must exactly fit
the longest name. The first row contains first three characters of team names (followed by one
or two spaces if the name was shorter than 3 characters). All teams must be given in the same
order as they appeared in the input list of teams.
Diagonal cells (except the first row and column) contain centered uppercase letter "X". All other
cells are either empty (three spaces) or contain game results for the games that have already
been played. Hosting team is in the row, guest team in the column.