QOJ.ac

QOJ

시간 제한: 2 s 메모리 제한: 256 MB 총점: 100

#22804. Kuhsprache

통계

Wenig bekannt ist, dass Kühe Wortspiele lieben: Kuhkreuzworträtsel, Wortsuchgitter und vieles mehr.

Zum Entwerfen brauchen sie Computerhilfe. Es gibt $N$ verschiedene Wörter ($2 \le N \le 20{,}000$), jedes höchstens 100 Zeichen, nur Kleinbuchstaben a..z.

Finde zwei Wörter mit längstem gemeinsamem Präfix: erste $C$ Zeichen gleich, $C$ maximal über alle Paare. Mindestens ein Paar teilt ein Präfix.

Haben mehr als zwei Paare dasselbe Maximum, wähle das Paar, dessen erstes Wort dem Anfang der gegebenen Liste am nächsten ist, und dessen anderes Wort mit maximalem Präfix ebenfalls möglichst früh steht.

Eingabe

  • Zeile $1$: ganze Zahl $N$.

  • Zeilen $2..N+1$: je ein Wort.

Ausgabe

Zwei Zeilen mit je einem Wort.

Beispiele

Eingabe 1

9
noon
is
lunch
for
most
noone
waits
until
two

Ausgabe 1

noon
noone

Aufgabenquelle: 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.