Mosaic
시간 제한2초메모리 제한1024 MB
3x3 검은 칸 개수를 담은 R x C 행렬이 주어질 때 이를 만들어 내는 흑백 그림을 하나 복원하거나, 존재하지 않으면 0을 출력한다.
문제
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 rows and columns, and recorded an -by- matrix, such that the number at row , column in the matrix equals the number of black unit squares in the -by- square region centered at the square at row , column .
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 and separated by a space.
The next lines contain nonnegative integers each, also separated by a space. Each number does not exceed .
출력
If such a painting exists, output 1 on the first line, and the painting over the next lines. Each line should be a string of length , 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.