Logo
(追記) (追記ここまで)

9221번 - A Voting Protocol 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB177375.000%

문제

Consider the following system for elections in which multiple candidates are to be elected. Suppose that there are k positions to fill. Each voter provides a ranked list of their k most preferred candidates, identified by a single lower case letter, with their first choice in position 1, their second choice in position 2, and so on.

The winning candidates are then chosen in a series of rounds. In each round, each voter votes for the first candidate in their list of preferences who has not yet been selected. The candidate with the greatest number of votes is added to the list of selected candidates. In case of a tie, all the tied candidates are added to the set of selected candidates, unless this would result in more than k selections. In this case, the tie is broken on alphabetical order. That is, if two further candidates are required, and 'a', 'x', and 'z' all have equally many votes, then 'a' and 'x' are selected. The election ends when k candidates have been selected.

입력

Input will consist of a number of elections. The first line of data for an election will contain two integers — the number of positions to be filled, k (1 ≤ k ≤ 26), and the number of voters, n (1 ≤ n ≤ 1000). This will be followed by n lines each containing a sequence of k lower case letters, without repetitions, i.e. noone can vote for the same person twice. The file will be terminated by a line containing two zeroes (0).

출력

Output will consist of a series of lines, one for each election. Each line will consist of the word ‘Election’, a space, the number of the election (a running number starting at 1), a colon and a space (‘: ’) and the list of selected candidates in selection order (m before g in Election 1), and alphabetically for selections in the same round (as in Election 2).

제한

예제 입력 1

2 3
gm
mg
mv
4 4
kqxj
qxjk
xjkq
jkqx
0 0

예제 출력 1

Election 1: mg
Election 2: jkqx

힌트

출처

ICPC > Regionals > South Pacific > South Pacific Region > New Zealand Programming Contest > NZPC 2004 H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /