QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 32 MB Puntuación total: 130

#17047. CHUCK

Estadísticas

给你一个 $R$ 行 $C$ 列的矩阵。矩阵中所有元素的绝对值均小于或等于 $10^4$。

你可以进行以下操作:

操作 表示法 示例
将矩阵的第 $i$ 行向右循环移动 $k$ 个元素 rotR i k rotR 3 1
将矩阵的第 $j$ 列向下循环移动 $k$ 个元素 rotS j k rotS 3 2
将第 $i$ 行的所有元素乘以 $-1$,当且仅当其中没有任何元素之前被乘以过 $-1$ negR i negR 2
将第 $j$ 列的所有元素乘以 $-1$,当且仅当其中没有任何元素之前被乘以过 $-1$ negS j negS 1

你需要使用有限次数的上述操作,使得矩阵中所有元素的和最大。

输入格式

输入的第一行包含两个整数 $R$ 和 $C$($1 \le R, C \le 100$),分别表示矩阵的行数和列数。

接下来的 $R$ 行,每行包含 $C$ 个整数。所有整数的绝对值均小于 $10^4$。

输出格式

输出的第一行应包含两个整数,分别表示可以获得的最大元素和以及所使用的操作次数。我们将操作次数记为 $T$。

接下来的 $T$ 行应包含能够达到该最大和的任意操作序列。每个操作应遵循上表定义的表示法。详情请参见样例。

子任务

  • 如果求得的和不是最大值、某个元素被乘以 $-1$ 超过一次,或者输出的操作序列无法得到该和,则该测试点得 $0$ 分。
  • 否则,得分取决于所使用的操作次数:

    • 对于 $T \le 5 \cdot R \cdot C$,你将获得该测试点 $100\%$ 的分数。
    • 对于 $5 \cdot R \cdot C < T \le 100\,000$,你将获得该测试点 $50\%$ 的分数。
    • 对于 $T > 100\,000$,你将获得该测试点 $0$ 分。

样例

输入 1

3 4
1 -2 5 200
-8 0 -4 -10
11 4 0 100

输出 1

345 2
rotS 2 1
negR 2

输入 2

3 3
8 -2 7
1 0 -3
-4 -8 3

输出 2

34 4
rotR 1 1
rotS 3 1
negR 2
negR 3

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.