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

7692번 - Election 다국어

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

문제

Given the voting preferences of a population of M people, you are to determine the winner of an election among N candidates, numbered 1, . . . , N. For this problem, the M people are partitioned into G “groups” where all members within a group have the same voting preferences. The candidate preferences for a group are specified by listing candidates from most preferred to least preferred. Election results are determined by an instant-runoff voting procedure.

In this method, the first choices of the M people in the population are counted and the least popular candidate is eliminated. In the event of a tie, the highest-numbered candidate is eliminated. Then, the eliminated candidate is removed from the preference list of all M individuals in the population, and again the least popular candidate is eliminated. This process repeats until only a single candidate is left.

입력

The input test file will contain multiple test cases. Each input test case begins with a single line containing the integers G and N where 2 ≤ N ≤ 5 and 1 ≤ G ≤ 20. The next G lines are of the format “Mi ai1 ai2 . . . aiN ” where 1 ≤ Mi ≤ 20 and ai1, . . . , aiN is a permutation of the integers 1, . . . , N. Mi is the number of individuals in the ith group, and ai1, . . . , aiN is the ordering of the N candidates from most preferred to least preferred for the ith group. The end-of-file is marked by a test case with G = N = 0 and should not be processed.

출력

For each input case, the program should print the winner of the election on a single line.

제한

예제 입력 1

3 4
10 1 4 2 3
15 3 2 1 4
12 4 3 2 1
3 2
10 1 2
10 1 2
20 2 1
0 0

예제 출력 1

4
1

힌트

출처

University > Stanford Local ACM Programming Contest > SLPC 2004 2번

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

출처

대학교 대회

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

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