QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 256 MB Puntuación total: 100

#22804. 牛语

Estadísticas

鲜为人知,牛喜欢文字游戏。它们有牛填字、找词网格及各种其他牛文字游戏。

设计某些游戏需要电脑帮助。有 $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.