E. Група

Вибачте, але цю сторінку ще не перекладено на українську мову For the sake of viewer convenience, the content is shown below in one of the available alternative languages. You may click one of the links to switch the site language to another available language.

2 sec, 256 M

The results of matches in a Champions League group and the sorting rules are given. Your task is to sort teams in right order.

The Champions League group consists of 4 teams falling there from 4 baskets in the order of their UEFA ranking descending. Each team plays one match at home and one away with each other team. Victory brings 3 points, draw brings 1 point and defeat brings nothing. After the group round teams are sorted by the points descending. Teams with equal points’ numbers are sorted by the result of mini-tournament, where only games between them are considered. The points got in the face meetings are considered primarily. Then the difference between scored and lost goals, the scored away goals number and total scored goals number are considered in the said order. If the teams are equal by the mini-tournament criteria, they are sorted by the difference between scored and lost goals and then by the scored goals number. If all the comparisons can’t differ the teams they are sorted by the UEFA ranking.

Input. The first input lines contain the clubs names in the UEFA ranking descending order. All the names consist of Latin letter and digits and are not longer than 30 symbols. Each of the following 12 lines contains a match result. In the example the input format is shown. All the teams are powerful and they can’t lose (or score) more than 9 balls.

Output. Output the teams in the sorted order.

Input Output
Barcelona

Inter

Dynamo

Rubin

Inter 0:0 Barcelona

Rubin 0:0 Dynamo

Dynamo 1:2 Barcelona

Rubin 1:1 Inter

Inter 2:2 Dynamo

Barcelona 1:2 Rubin

Dynamo 1:2 Inter

Rubin 0:0 Barcelona

Barcelona 2:0 Inter

Dynamo 3:1 Rubin

Inter 2:0 Rubin

Barcelona 2:0 Dynamo

Barcelona

Inter

Rubin

Dynamo

Idea – Oleg Alexandrovich Petrov

About the post author Igor Mazurok (5 Posts)

PhD in Computer Science, Associate professor of Department Applied Mathematics of Odessa I.I.Mechnikov National University, Ukraine KBIS Software Developer

Author Info

Igor Mazurok

PhD in Computer Science, Associate professor of Department Applied Mathematics of Odessa I.I.Mechnikov National University, Ukraine
KBIS Software Developer

Leave a Reply