QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 256 MB مجموع النقاط: 100 قابلة للهجوم ✓

#7882. 语言学谜题

الإحصائيات

在准备国际语言学奥林匹克竞赛时,Ham 先生遇到了一种未知的语言 X。他得到了一个整数 $n$ ($2 \le n \le 52$) 以及用语言 X 书写的 $n^2$ 个数字。这 $n^2$ 个数字由以下规则生成:

  • 生成一个序列 $a_0, a_1, \dots, a_{n^2-1}$,满足对于所有 $0 \le i, j < n$,都有 $a_{n \cdot i + j} = i \cdot j$。
  • 打乱该序列。

Ham 先生是一位经验丰富的 ICLCer。他发现了语言 X 的一些基本规则:

  • 语言 X 中有 $n$ 个不同的符号。如果 $n \le 26$,Ham 先生使用前 $n$ 个小写字母来表示它们。否则,他使用前 26 个小写字母和前 $n-26$ 个大写字母来表示它们。
  • 语言 X 中的数字采用 $n$ 进制书写。每个数位由语言 X 中的一个符号表示。
  • 与阿拉伯数字一样,数位从高位到低位书写,即 $a \cdot n + b$ 写为 $ab$ 而不是 $ba$。没有前导零,即 $a$ 写为 $a$ 而不是 $0a$。

Ham 先生想知道对于每个 $0 \le i < n$,语言 X 中哪个符号代表数字 $i$。他向你寻求帮助。

输入格式

每个测试包含多个测试用例。第一行包含测试用例的数量 $T$ ($1 \le T \le 50$)。接下来是各测试用例的描述。

每个测试用例的第一行包含一个整数 $n$ ($2 \le n \le 52$),即语言 X 中的符号数量。 第二行包含 $n^2$ 个字符串 $s_1, s_2, \dots, s_{n^2}$,即语言 X 中的数字。每个字符串最多由 2 个大小写字母组成。

保证答案存在。

输出格式

输出一个长度为 $n$ 的字符串,其中第 $i$ 个字符是语言 X 中代表数字 $i-1$ 的符号。 如果有多个答案,输出其中任意一个即可。

样例

输入 1

2
3
a b a b b b b c cc
4
d d d d d c b a d b cd cb d a cb bc

输出 1

bca
dcba

输入 2

2
4
d a a bc ba bc b a a a d a a cb c c
4
a b da b b d ad b db b a c da b c b

输出 2

abcd
bdac

说明

在第一个样例的第一个测试用例中,字母 b 代表数字 0,字母 c 代表数字 1,字母 a 代表数字 2。输入中给出的数字为 1, 0, 1, 0, 0, 0, 0, 2, 4。

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.