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

32468번 - Mosaic 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB (추가 메모리 없음)8610710.448%

문제

Mosa is an abstract artist. All of her paintings can be represented as a rectangular grid of black and white unit squares.

Lina is an art collector. His favorite hobby is counting black squares in Mosa’s paintings. One day, he took one of her paintings of $R$ rows and $C$ columns, and recorded an $R$-by-$C$ matrix, such that the number at row $r,ドル column $c$ in the matrix equals the number of black unit squares in the 3ドル$-by-3ドル$ square region centered at the square at row $r,ドル column $c$.

Unfortunately, the very next day Lina found that the artwork is missing! All he has now is the matrix of numbers. Can you help Lina recover Mosa’s painting?

Lina might have made a mistake while writing down the numbers, so it is possible that such a painting does not exist for a given matrix.

입력

The first line contains two integers $R$ and $C$ separated by a space.

The next $R$ lines contain $C$ nonnegative integers each, also separated by a space. Each number does not exceed 9ドル$.

출력

If such a painting exists, output 1 on the first line, and the painting over the next $R$ lines. Each line should be a string of length $C,ドル consisting of characters B (for Black) and W (for White). If multiple paintings satisfy the condition, output any one of them.

If such a painting does not exist, output 0 on the first line.

제한

  • 1ドル\le R,C\le 1,円 000$

예제 입력 1

5 5
4 6 6 6 4
6 8 8 8 6
6 8 8 8 6
6 8 8 8 6
4 6 6 6 4

예제 출력 1

1
BBBBB
BBBBB
BBWBB
BBBBB
BBBBB

예제 입력 2

4 4
0 1 0 1
1 0 1 0
0 1 0 1
1 0 1 0

예제 출력 2

0

노트

출처

University > KAIST > KAIST ICPC Mock Competition > 2024 KAIST 14th ICPC Mock Competition H번

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

출처

대학교 대회

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

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