402381: GYM100741 C Reordering Ones

Memory Limit:64 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Reordering Onestime limit per test0.5 secondsmemory limit per test64 megabytesinputstandard inputoutputstandard output

Given a board of size N * M. The rows are numbered from 1 to N, and the columns are numbered from 1 to M. Each cell of the board contains either 0 or 1.

You can apply 2 types of operations:

  1. swapCol(i, j), meaning you can swap 2 different columns
  2. swapRow(i, j), meaning you can swap 2 different rows.

You have a function valid(x1, y1, x2, y2), which returns true if and only if every cell in the sub-board with 2 opposite corners (x1, y1), (x2, y2) contains all 1.

You need to find maximum value of (x0 + y0), such that it is possible to apply the operations, so that valid(1, 1, x0, y0) = true. However, everybody is only interested in solutions where x0 + y0 > max(m, n).

Input

On the first line of input there are two integers N and M (1 ≤ N, M ≤ 1000) – the size of the matrix. On the following N lines there are M integers each – the elements of the matrix, either 0 or 1.

Output

On the first line of output print the values x0 and y0 giving the maximal possible sum (x0 + y0).

On the next line of output print the number R – the number of operations.

On the following R lines output the operations itself in such format T i j, where T is the what is swapped ('C' for columns and 'R' for rows), i and j are the indexes of rows/columns being swapped.

If there are multiple solutions, output any of them.

If there is no solution such that x0 + y0 > max(m, n), print single line with "0 0".

ExamplesInput
3 3
0 1 1
1 1 0
1 1 1
Output
1 3
1
R 1 3
Input
3 1
0
1
1
Output
0 0

加入题单

上一题 下一题 算法标签: