codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

19A.md (2571B)


      1 Source: https://codeforces.com/problemset/problem/19/A
      2 
      3 A. World Football Cup
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 64 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Everyone knows that 2010 FIFA World Cup is being held in South Africa now. By the decision of BFA (Berland's Football Association) next World Cup will be held in Berland. BFA took the decision to change some World Cup regulations:
     22 
     23 * the final tournament features *n* teams (*n* is always even)
     24 * the first *n* / 2 teams (according to the standings) come through to the knockout stage
     25 * the standings are made on the following principle: for a victory a team gets 3 points, for a draw — 1 point, for a defeat — 0 points. In the first place, teams are ordered in the standings in decreasing order of their points; in the second place — in decreasing order of the difference between scored and missed goals; in the third place — in the decreasing order of scored goals
     26 * it's written in Berland's Constitution that the previous regulation helps to order the teams without ambiguity.
     27 
     28 You are asked to write a program that, by the given list of the competing teams and the results of all the matches, will find the list of teams that managed to get through to the knockout stage.
     29 
     30 Input
     31 
     32 The first input line contains the only integer *n* (1 ≤ *n* ≤ 50) — amount of the teams, taking part in the final tournament of World Cup. The following *n* lines contain the names of these teams, a name is a string of lower-case and upper-case Latin letters, its length doesn't exceed 30 characters. The following *n*·(*n* - 1) / 2 lines describe the held matches in the format name1-name2 num1:num2, where *name*1, *name*2 — names of the teams; *num*1, *num*2 (0 ≤ *num*1, *num*2 ≤ 100) — amount of the goals, scored by the corresponding teams. Accuracy of the descriptions is guaranteed: there are no two team names coinciding accurate to the letters' case; there is no match, where a team plays with itself; each match is met in the descriptions only once.
     33 
     34 Output
     35 
     36 Output *n* / 2 lines — names of the teams, which managed to get through to the knockout stage in lexicographical order. Output each name in a separate line. No odd characters (including spaces) are allowed. It's guaranteed that the described regulations help to order the teams without ambiguity.
     37 
     38 Examples
     39 
     40 Input
     41 
     42 ```
     43 4  
     44 A  
     45 B  
     46 C  
     47 D  
     48 A-B 1:1  
     49 A-C 2:2  
     50 A-D 1:0  
     51 B-C 1:0  
     52 B-D 0:3  
     53 C-D 0:3
     54 ```
     55 
     56 Output
     57 
     58 ```
     59 A  
     60 D
     61 ```
     62 
     63 Input
     64 
     65 ```
     66 2  
     67 a  
     68 A  
     69 a-A 2:1
     70 ```
     71 
     72 Output
     73 
     74 ```
     75 a
     76 ```