QOJ.ac

QOJ

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

#11231. 熊猫先生与神奇动物

Estadísticas

熊猫先生热爱神奇动物,他打算使用一个魔法咒语来找出它们在哪里。 给定 $N$ 个字符串 $S_1, S_2, \dots, S_N$,其中 $S_i$ 仅包含小写字母。魔法咒语是满足以下条件的字符串:它是仅在第一个字符串中作为子串出现的最短字符串。如果存在至少一个这样的解,请输出字典序最小的那一个。 如果不存在解,则输出 “Impossible”。

输入格式

输入的第一行包含测试用例的数量 $T$。接下来是 $T$ 个测试用例。 每个测试用例包含一个整数 $N$,表示字符串的数量。 接下来有 $N$ 行,每行包含一个非空字符串 $S_i$,仅包含小写字母。

输出格式

对于每个测试用例,输出一行 “Case #x: y”,其中 $x$ 是测试用例编号(从 1 开始),$y$ 是答案字符串或 “Impossible”。

数据范围

  • $1 \le T \le 42$
  • $2 \le N \le 50000$
  • $N \le |S_1| + |S_2| + \dots + |S_N| \le 250000$
  • 所有测试用例中 $|S_i|$ 的总和不超过 $3 \times 10^6$

样例

输入 1

3
2
aba
bab
3
qnu
cvbb
bnu
3
a
aa
aaa

输出 1

Case #1: aba
Case #2: q
Case #3: Impossible

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.