QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 256 MB Total points: 100

#15397. Number Maze

統計

在“数字迷宫”中,一位神秘的代码大师守卫着关卡。他挡住去路并微笑着说:“勇敢的冒险者,通过这道门可不容易!代码大师手中掌握着一个古老的数字代码,它可以被重组成多种组合。旅行者必须从这些组合中选择两个数字代码,并展示它们的 $x\text{A}y\text{B}$ 结果,否则这道门将永远困住旅行者!”

$x\text{A}y\text{B}$ 的规则如下:

  • 每个 $\text{A}$ 表示两个代码中有一个数字在数值和位置上都匹配。
  • 每个 $\text{B}$ 表示两个代码中有一个数字在数值上匹配,但位置不匹配。

例如:

比较的代码 结果 说明
5234 vs. 5789 1A0B 只有数字 5 在数值和位置上都匹配。
5634 vs. 6589 0A2B 数字 5 和 6 仅在数值上匹配,但位置不同。
1847 vs. 6149 1A1B 数字 4 在数值和位置上都匹配,而数字 1 仅在数值上匹配。

给定一个基础数字代码 $n$,它可以是 $\{12, 123, 1234\}$ 中的一个。考虑 $n$ 的数字的所有可能排列,并将它们按升序排列。设第 $j$ 个和第 $k$ 个排列(从 1 开始计数)为旅行者选择的两个数字代码。

你的任务是比较这两个排列,并根据上述规则确定它们的 $x\text{A}y\text{B}$ 结果。

输入格式

每个测试包含多个测试用例。第一行包含一个整数 $t$,表示代码大师将进行的测试数量。接下来是各测试用例的描述。

每个测试用例仅包含一行,包含三个整数 $n$、$j$ 和 $k$,分别代表基础数字代码以及要比较的两个排列的索引。

  • $1 \le t \le 1000$
  • $n \in \{12, 123, 1234\}$
  • $j$ 和 $k$ 均为 $n$ 的数字排列的有效索引。

输出格式

对于每个测试用例,以 $x\text{A}y\text{B}$ 的格式输出结果,其中 $x$ 和 $y$ 为整数。

样例

输入 1

3
12 1 2
123 1 2
123 2 5

输出 1

0A2B
1A2B
1A2B

输入 2

3
1234 15 9
1234 1 24
1234 1 1

输出 2

2A2B
0A4B
4A0B

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.