QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22804. 소 언어

Statistics

잘 알려지지 않았지만 소는 단어 게임을 좋아합니다. 소 십자말, 단어 찾기 격자, 다른 여러 게임이 있습니다.

일부 게임 설계에 컴퓨터 도움이 필요합니다. 서로 다른 단어 $N$개($2 \le N \le 20{,}000$)는 각각 최대 100글자, 소문자 a..z만입니다.

공통 접두사가 가장 긴 두 단어를 찾습니다. 앞 $C$글자가 같고 $C$가 모든 쌍의 최대 길이입니다. 공통 접두사가 있는 쌍이 하나 이상 보장됩니다.

최대 길이를 가진 쌍이 둘보다 많으면 첫 단어가 주어진 목록 처음에 가장 가까우며, 다른 최대 접두사 단어도 처음에 가장 가까운 쌍을 고릅니다.

입력

  • $1$번 줄: 정수 $N$.

  • $2..N+1$번 줄: 각각 단어 하나.

출력

두 줄에 각각 단어 하나.

예제

입력 1

9
noon
is
lunch
for
most
noone
waits
until
two

출력 1

noon
noone

문제 제공: Dan Adkins, 2001.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.