Logo
(追記) (追記ここまで)

21877번 - Innoforest 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB128763.636%

문제

Trees in Innopolis are exceptional, if you water an innotree (Innopolis Tree), it will grow by number of litres you have watered it. In other words if you water innotree of height $h$ by $x$ litres of water then it will have new height of $h + x$.

Innoforest (Innopolis Forest) is a $n \times m$ grid, each cell of the grid contains one innotree. Irrigation system in innoforest contains $n + m$ canals: one for each row and column. The irrigation system in one operation can water all trees along one of canals by the same amount of water.

The mayor of Innopolis wants to transform the innoforest by performing some operations on the irrigation system. For each tree in innoforest you know its current height and the desired height. Your task is to find the sequence of operations that transforms the innoforest to the desired shape.

입력

First line contains two numbers $n$ and $m$ (1ドル \le n, m \le 1000$).

Then $n$ lines follow, each line contains $m$ numbers $a_{i,j},ドル current heights of the trees in innoforest (1ドル \le a_{i,j} \le 10^9$).

Then $n$ more lines follow, each line contains $m$ numbers $b_{i,j},ドル desired heights of the trees (1ドル \le b_{i,j} \le 10^9$).

출력

The first line should contain the number of operations $k$ (0ドル \le k \le 10^6$), then $k$ lines contain the description of operations.

  • "R r x" The system will water the $r$-th row by $x$ litres. (1ドル \le r \le n,ドル 1ドル \le x \le 10^9$).
  • "C c x" The system will water the $c$-th column by $x$ litres. (1ドル \le c \le m,ドル 1ドル \le x \le 10^9$).

If it is impossible to transform the innoforest to the desired shape, output only one integer -1.

Notice that it is not required to minimize the number of operations, only make sure that it does not exceed 10ドル^6$.

제한

서브태스크

번호배점제한
111

$n = 1,ドル $m \le 1000,ドル $a_{i, j}, b_{i, j} \le 10^9$

223

$n, m \le 50,ドル $a_{i, j}, b_{i, j} \le 50$

321

$n, m \le 300,ドル $a_{i, j}, b_{i, j} \le 300$

445

$n, m \le 1000,ドル $a_{i, j}, b_{i, j} \le 10^9$

예제 입력 1

1 1
4
9

예제 출력 1

2
C 1 2
R 1 3

예제 입력 2

3 3
2 2 2
2 2 2
2 2 2
1 1 1
1 1 1
1 1 1

예제 출력 2

-1

예제 입력 3

3 3
1 2 3
4 5 6
7 8 9
2 4 4
5 7 7
7 9 9

예제 출력 3

3
R 1 1
R 2 1
C 2 1

힌트

출처

Contest > Innopolis Open in Informatics > Innopolis Open, First elimination round, 2018-2019 C번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /