QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 512 MB Puntuación total: 100

#5289. MalnaRISC

Estadísticas

MalnaRISC 的汇编语言包含一条指令:

  • CMPSWP Ri Rj – 如果 $R_i > R_j$ 成立,则交换寄存器 $R_i$ 和 $R_j$ 中的值。

MalnaRISC 的特殊之处在于,写在同一行的所有指令将在一个纳秒内并行执行。自然地,在同一行中,每个寄存器最多只能作为参数使用一次。

已知寄存器 $R_1, R_2, \dots, R_N$ 中存储了一些整数。请编写一段高效的汇编代码,将这些值按非递减顺序排序。

输入格式

仅一行,包含一个整数 $N$。

输出格式

第一行输出一个整数 $t$,表示程序的执行时间(以纳秒为单位)。

在接下来的 $t$ 行中,输出用于对 $N$ 个寄存器中的值进行排序的汇编代码。每一行应至少包含一条指令,且每个寄存器在同一行中只能被提及一次。每条指令必须采用 CMPSWP Ri Rj ($1 \le i, j \le N$) 的形式,同一行中的指令需用单个空格字符分隔。

子任务

子任务 $N$ $t_1$ $t_2$ $t_3$ 分数
1 8 28 12 6 10
2 13 78 22 10 10
3 16 120 28 10 10
4 32 496 60 15 10
5 53 1378 102 21 10
6 64 2016 124 21 10
7 73 2628 142 28 10
8 82 3321 160 28 10
9 91 4095 178 29 10
10 100 4950 196 30 10

如果你针对某个子任务输出了一个正确的程序,且该程序在 $t$ 纳秒内正确地对寄存器中的值进行了排序,那么你的解将根据以下表达式进行评分:

$$points(t) = \begin{cases} 0 & t > t_1 \\ 1 + \frac{2}{t - t_2} & t_1 \ge t > t_2 \\ 3 + \frac{7(t_2 - t + 1)}{t_2 - t_3} & t_2 \ge t > t_3 \\ 10 & t_3 \ge t \end{cases}$$

每个子任务的得分将四舍五入到小数点后两位。总得分通过将这些分数相加并以相同方式四舍五入得到。

样例

输入 1

2

输出 1

1
CMPSWP R1 R2

输入 2

3

输出 2

3
CMPSWP R1 R2
CMPSWP R1 R3
CMPSWP R2 R3

输入 3

4

输出 3

4
CMPSWP R1 R3
CMPSWP R2 R4
CMPSWP R1 R2 CMPSWP R3 R4
CMPSWP R2 R3

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.