Universal Cup Judging System

Universal Cup

Límite de tiempo: 2.0 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓
Estadísticas

给定 $N$ 个字符串 $S_1, \dots, S_N$,每个字符串均由小写英文字母组成,长度均为 $M$。

初始时,令 $X = S_1$,并执行 $N - 1$ 次以下操作。

在第 $i$ 次操作中,令 $Y$ 为 $X$ 与 $S_{i+1}$ 按此顺序拼接而成的字符串。然后,选择 $Y$ 的任意一个长度为 $M$ 的连续子串,并将 $X$ 替换为该子串。

输出 $X$ 最终可能得到的字典序最小的字符串。

输入格式

第一行包含整数 $N, M$。($2 \le N \le 2000, 1 \le M \le 2000$)

接下来 $N$ 行,每行包含一个长度为 $M$ 的字符串 $S_i$,由小写英文字母组成。

输出格式

输出答案。

样例

输入格式 1

2 3
cat
cut

输出格式 1

atc

说明

在第一个样例中,初始时 $X = \text{cat}$。 在第一次操作中,$Y = \text{catcut}$。如果我们选择从第 2 个字符到第 4 个字符的连续子串,则 $X = \text{atc}$,这是字典序最小的结果。

输入格式 2

2 1
a
b

输出格式 2

a

输入格式 3

3 8
jastaway
tatesoto
soryuusi

输出格式 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.