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

3161번 - izbori 스페셜 저지다국어

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

문제

Presidential elections are underway in a small country. There are a total of M citizens choosing between N candidates labeled 1 to N.

Each voter fills his ballot by listing all the candidates in order of preference – they put their favorite candidate in the first place, the second one in the second place, …, the least favored candidate in the last place.

We say that candidate A defeated candidate B if the number of voters that put candidate A in front of candidate B is greater than the number of voters that put candidate B in front of candidate A. For a candidate A we define his score as the total number of candidates he defeated. We say that a candidate is a winner of the elections if his score is greater than or equal to the score of every other candidate.

Write a program that, given the votes of the citizens, finds the winner (or winners) of the elections.

입력

The first line of input contains two integers M and N, 1 ≤ M,N ≤ 50, M is odd.

Each of the next M lines contains sequence of N numbers, the contents of each citizen's ballot.

출력

If there is only one winner, output his label on the first and only line.

If there are more winners, output their labels in arbitrary order, each label in its own line.

제한

예제 입력 1

1 3
1 2 3

예제 출력 1

1

예제 입력 2

3 4
4 3 2 1
1 4 3 2
2 1 4 3

예제 출력 2

1
4

예제 입력 3

5 5
1 2 3 4 5
5 4 3 2 1
1 2 3 4 5
5 4 3 2 1
3 1 2 4 5

예제 출력 3

3

힌트

출처

Olympiad > Croatian Highschool Competitions in Informatics > 2006 > National Competition #1 - Juniors 1번

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

출처

대학교 대회

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

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