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

4701번 - Party Games 다국어

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

문제

You’ve been invited to a party. The host wants to divide the guests into 2 teams for party games, with exactly the same number of guests on each team. She wants to be able to tell which guest is on which team as she greets them when they arrive. She’d like to do so as easily as possible, without having to take the time to look up each guest’s name on a list.

Being a good computer scientist, you have an idea: give her a single string, and all she has to do is compare the guest’s name alphabetically to that string. To make this even easier, you would like the string to be as short as possible.

Given the unique names of n party guests (n is even), find the shortest possible string S such that exactly half the names are less than or equal to S, and exactly half are greater than S. If there are multiple strings of the same shortest possible length, choose the alphabetically smallest string from among them.

입력

There may be multiple test cases in the input.

Each test case will begin with an even integer n (2 ≤ n ≤ 1, 000) on its own line.

On the next n lines will be names, one per line. Each name will be a single word consisting only of capital letters and will be no longer than 30 letters.

The input will end with a 0 on its own line.

출력

For each case, print a single line containing the shortest possible string (with ties broken in favor of the alphabetically smallest) that your host could use to separate her guests. The strings should be printed in all capital letters.

제한

예제 입력 1

4
FRED
SAM
JOE
MARGARET
2
FRED
FREDDIE
2
JOSEPHINE
JERRY
2
LARHONDA
LARSEN
0

예제 출력 1

K
FRED
JF
LARI

힌트

출처

ICPC > Regionals > North America > Mid-Atlantic Regional > 2012 Mid-Atlantic Regional Programming Contest E번

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

출처

대학교 대회

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

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