#P8409. [COCI 2009/2010 #5] CHUCK
[COCI 2009/2010 #5] CHUCK
Problem Description
You are given a matrix with rows and columns, where . Please use the following operations (as few times as possible) to make as large as possible.
| Operation | Example | |
|---|---|---|
rotR i k cyclically shifts the elements of row to the right by 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 downward by 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 by . This operation is valid if and only if none of the elements in that row has been multiplied by 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 by . This operation is valid if and only if none of the elements in that column has been multiplied by 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: .
The next lines: the matrix .
Output Format
The first line contains two integers: the first integer is the maximum value of , and the second integer is the number of operations .
The next 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: , .
Scoring
If you output an incorrect maximum sum, or any operation you perform is invalid, you will get points for that test case. Otherwise:
If , you will get full points for that test case.
If , you will get of the points for that test case.
If , you will get points for that test case.
The score of this problem follows the original COCI settings, with a full score of .
Translated by ChatGPT 5