QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 1024 MB 満点: 100

#6319. 并行处理 (简单)

統計

这是本题的简单版本。两个版本之间唯一的区别在于 $N$ 的数据范围。 给定一个神秘的幺半群 $(M, \oplus)$ 和 4 个用于计算的 CPU。使用 4 个 CPU 并行计算序列 $A = (A_1, A_2, \dots, A_N)$ 的累积 $\oplus$ 和,并最小化操作次数。

实现细节

该程序可以处理 2004 个变量 $A[1], A[2], \dots, A[2000], C_1, C_2, C_3, C_4$。每个变量可以存储一个整数序列,$A[i]$ ($1 \le i \le 2000$) 初始化为 $A[i] = (i)$。(此处 $(i)$ 表示仅包含整数 $i$ 的序列。)

在执行结束时,必须满足以下条件: * 对于每个 $i = 1, 2, \dots, N$,满足 $A[i] = (1, 2, \dots, i)$。

输入格式

输入格式如下:

$N$

  • 所有输入值均为整数。
  • $2 \le N \le 16$

输出格式

设 $L$ 为最小指令数。按以下格式输出:

$L$ $\text{op}_1$ $\text{op}_2$ $\vdots$ $\text{op}_L$

其中 $\text{op}_i$ ($1 \le i \le L$) 表示第 $i$ 次操作。每条指令包含 12 个整数 $c_1, a_1, b_1, c_2, a_2, b_2, c_3, a_3, b_3, c_4, a_4, b_4$,应按以下 4 行格式输出:

$c_1 \ a_1 \ b_1$ $c_2 \ a_2 \ b_2$ $c_3 \ a_3 \ b_3$ $c_4 \ a_4 \ b_4$

此处,每个整数必须在 1 到 2000 之间。

对于每条指令,按顺序执行以下操作:

  1. 将 $\text{concat}(A[a_1], A[b_1])$ 赋值给 $C_1$。
  2. 将 $\text{concat}(A[a_2], A[b_2])$ 赋值给 $C_2$。
  3. 将 $\text{concat}(A[a_3], A[b_3])$ 赋值给 $C_3$。
  4. 将 $\text{concat}(A[a_4], A[b_4])$ 赋值给 $C_4$。
  5. 将 $C_1$ 赋值给 $A[c_1]$。
  6. 将 $C_2$ 赋值给 $A[c_2]$。
  7. 将 $C_3$ 赋值给 $A[c_3]$。
  8. 将 $C_4$ 赋值给 $A[c_4]$。

此处,$\text{concat}(x, y)$ 表示将序列 $x$ 和 $y$ 按该顺序连接后得到的序列。

样例

输入格式 1

2

输出格式 1

1
2 1 2
2000 2000 2000
2000 2000 2000
2000 2000 2000

说明

在第一个样例中,第一次操作将 $A[2]$ 变为 $(1, 2)$,将 $A[2000]$ 变为 $(2000, 2000)$。执行结束时,$A[1] = (1)$ 且 $A[2] = (1, 2)$,满足题目要求。

输入格式 2

4

输出格式 2

2
2 1 2
4 3 4
2000 2000 2000
2000 2000 2000
3 2 3
4 2 4
2000 2000 2000
2000 2000 2000

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.