Universal Cup Judging System

Universal Cup

Time Limit: 2.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

Bạn được cho $N$ xâu $S_1, \dots, S_N$, mỗi xâu gồm các chữ cái tiếng Anh viết thường và có độ dài $M$.

Ban đầu, đặt $X = S_1$, và thực hiện thao tác sau $N - 1$ lần.

Trong thao tác thứ $i$, gọi $Y$ là xâu được tạo thành bằng cách nối $X$ và $S_{i+1}$ theo thứ tự này. Sau đó, chọn bất kỳ xâu con liên tiếp nào của $Y$ có độ dài $M$, và thay thế $X$ bằng xâu con đó.

Hãy in ra xâu có thứ tự từ điển nhỏ nhất có thể là giá trị cuối cùng của $X$.

Dữ liệu vào

Dòng đầu tiên chứa các số nguyên $N, M$ theo thứ tự đó ($2 \le N \le 2000, 1 \le M \le 2000$).

Mỗi dòng trong $N$ dòng tiếp theo chứa một xâu $S_i$ có độ dài $M$, gồm các chữ cái tiếng Anh viết thường.

Dữ liệu ra

In ra kết quả.

Ví dụ

Dữ liệu vào 1

2 3
cat
cut

Dữ liệu ra 1

atc

Ghi chú

Trong ví dụ đầu tiên, ban đầu $X = \text{cat}$. Trong thao tác đầu tiên, $Y = \text{catcut}$. Nếu chúng ta chọn xâu con liên tiếp từ ký tự thứ 2 đến ký tự thứ 4, thì $X = \text{atc}$, đây là xâu có thứ tự từ điển nhỏ nhất có thể.

Dữ liệu vào 2

2 1
a
b

Dữ liệu ra 2

a

Dữ liệu vào 3

3 8
jastaway
tatesoto
soryuusi

Dữ liệu ra 3

asoryuus

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1629EditorialOpenO(n^3 log \sum /w) 做法tzl_Dedicatus5452026-04-27 11:23:46View
#1523EditorialOpen题解jiangly2026-04-15 16:03:12View
#1506EditorialOpenO(n^3) 做法incent2026-04-12 21:25:08View

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.