Programming contests

ACM ICPC programozó csapatverseny, házi forduló, 2017. október 29.

October 29, 2017 10:00 AM – October 29, 2017 3:00 PM

Vote

Benin is organizing a presidential election on March 6, 2016. Several candidates submitted their applications for this presidential election. CENA (“Commission Électorale Nationale Autonome”) is responsible for managing the election.

According to Article 15 of the Beninese electoral code, CENA is responsible for the preparation, organization, and supervision of voting and for accumulating the results.

As a great programmer, you are asked to help CENA to accumulate the results of the presidential election.

Input Specification

The first line of the input contains a single integer P (1 ≤ P ≤ 1000), which is the number of data sets that follow. Each data set begins with a line containing the number n of the candidates (1 ≤ n ≤ 100), a space, and the number m of results to accumulate (1 ≤ m ≤ 1000). This line is followed by n lines, containing the names of the candidates, one per line. Each of the next m lines contains a name X of a candidate, the result (number of votes) R of the candidate, and the place C of the vote, separated by single spaces. X and C are strings containing at most 1000 characters and no spaces. R is a positive integer.

Output Specification

For each data set, if there is only one winner, generate one line of output with the text “VOTE i: THE WINNER IS ”, followed by the name of the winner, followed by a space and the total number of votes for the winner. If the winner cannot be determined, generate the following output: “VOTE i: THERE IS A DILEMMA”. i is the number of the data set.

Sample Input

  1. 2
  2. 3 4
  3. Bignon
  4. Akwaba
  5. Sessi
  6. Bignon 1000 Gbegamey
  7. Sessi 1000 Yenawa
  8. Akwaba 5 Vodje
  9. Akwaba 996 Yenawa
  10. 2 3
  11. Sena
  12. Sedjro
  13. Sedjro 6003 Malanville
  14. Sena 6000 Kpankpan
  15. Sena 3 Godomey
download as text file

Output for Sample Input

  1. VOTE 1: THE WINNER IS Akwaba 1001
  2. VOTE 2: THERE IS A DILEMMA
download as text file
University of Debrecen; Faculty of Informatics; v. 03/01/2019