QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 256 MB 總分: 100

#22804. Tiếng bò

统计

Ít người biết bò thích trò chơi từ: ô chữ bò, lưới tìm từ và nhiều trò khác.

Thiết kế cần máy tính giúp. Có $N$ từ khác nhau ($2 \le N \le 20{,}000$), mỗi từ tối đa 100 ký tự, chỉ chữ thường a..z.

Tìm hai từ có tiền tố chung dài nhất: $C$ ký tự đầu giống nhau và $C$ lớn nhất trong mọi cặp. Bảo đảm ít nhất một cặp chung tiền tố.

Nếu hơn hai cặp cùng độ dài tối đa, chọn cặp có từ đầu gần đầu danh sách cho nhất, rồi từ còn lại có tiền tố tối đa cũng gần đầu nhất.

Dữ liệu vào

  • Dòng $1$: số nguyên $N$.

  • Các dòng $2..N+1$: mỗi dòng một từ.

Dữ liệu ra

Hai dòng, mỗi dòng một từ.

Ví dụ

Dữ liệu vào 1

9
noon
is
lunch
for
most
noone
waits
until
two

Dữ liệu ra 1

noon
noone

Nguồn bài: 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.