#P8409. [COCI 2009/2010 #5] CHUCK

    ID: 9504 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>数学2009Special JudgeCOCI(克罗地亚)

[COCI 2009/2010 #5] CHUCK

Problem Description

You are given a matrix aa with RR rows and CC columns, where ai,j104|a_{i,j}| \le 10^4. Please use the following operations (as few times as possible) to make ijai,j\sum_i \sum_j a_{i,j} as large as possible.

Operation Example
rotR i k cyclically shifts the elements of row ii to the right by kk positions $\left(\begin{array}{ccc}1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ 10 & 11 & 12\end{array}\right)$ $\xrightarrow{\operatorname{rotR} 3\ 1}\left(\begin{array}{ccc}1 & 2 & 3 \\ 4 & 5 & 6 \\ 9 & 7 & 8 \\ 10 & 11 & 12\end{array}\right)$
rotS j k cyclically shifts the elements of column jj downward by kk positions $\xrightarrow{\text { rotS } 3\ 2}\left(\begin{array}{ccc}1 & 2 & 9 \\ 4 & 5 & 12 \\ 7 & 8 & 3 \\ 10 & 11 & 6\end{array}\right)$
negR i multiplies all elements in row ii by 1-1. This operation is valid if and only if none of the elements in that row has been multiplied by 1-1 before $\xrightarrow{\text { negR } 2}\left(\begin{array}{ccc}1 & 2 & 3 \\ -4 & -5 & -6 \\ 7 & 8 & 9 \\ 10 & 11 & 12\end{array}\right)$
negS j multiplies all elements in column jj by 1-1. This operation is valid if and only if none of the elements in that column has been multiplied by 1-1 before $\left(\begin{array}{ccc}1 & 2 & 3 \\ 0 & 0 & 0 \\ 7 & 8 & 9 \\ 10 & 11 & 12\end{array}\right)$ $\xrightarrow{\text { negS } 1}\left(\begin{array}{ccc}-1 & 2 & 3 \\ 0 & 0 & 0 \\ -7 & 8 & 9 \\ -10 & 11 & 12\end{array}\right)$

Input Format

The first line: r,cr, c.
The next rr lines: the matrix aa.

Output Format

The first line contains two integers: the first integer is the maximum value of ijai,j\sum_i \sum_j a_{i,j}, and the second integer is the number of operations tt.
The next tt lines each contain one operation.

3 4
1 -2 5 200
-8 0 -4 -10
11 4 0 100
345 2
rotS 2 1
negR 2
3 3
8 -2 7
1 0 -3
-4 -8 3
34 4
rotR 1 1
rotS 3 1
negR 2
negR 3

Hint

Constraints: 1R,C1001 \le R,C \le 100, Ai,js104|A_{i,j}|s \le 10^4.

Scoring

If you output an incorrect maximum sum, or any operation you perform is invalid, you will get 00 points for that test case. Otherwise:

If t5RCt \le 5 \cdot RC, you will get full points for that test case.

If 5RC<T<1055 \cdot RC < T < 10^5, you will get 50%50\% of the points for that test case.

If t>105t > 10^5, you will get 00 points for that test case.

The score of this problem follows the original COCI settings, with a full score of 130130.

Translated by ChatGPT 5