EVANESCENT

시간 제한3초메모리 제한1024 MB

요약
체비쇼프 거리 합으로 만들어진 격자 피해 값이 주어질 때, 이를 만드는 폭발 위치 집합을 하나 복원한다.
난이도

어려움10점 중 9점

유형
분할 정복, 구현, 수학, 시뮬레이션
정답자
아직 제출이 없습니다

문제

Reiuji Utsuho and Hakurei Reimu decided to compete to see whose abilities were superior.

Their duel takes place on a grid of size (N+2)×(N+2)(N+2) \times (N+2). Columns are numbered from 00 to N+1N+1 from left to right, and rows are numbered from 00 to N+1N+1 from top to bottom. The cell in row ii and column jj is denoted as (i,j)(i,j).

Utsuho can use her ability to cause explosions in certain cells of the grid. There is no limit on the number of cells she can choose, but explosions are only allowed in the inner N×NN \times N cells. More precisely, if an explosion occurs at cell (i,j)(i,j), then its row and column indices must satisfy 1≤i,j≤N1 \le i,j \le N.

Uniquely, the explosions Utsuho uses in this battle are special --- Their destructive power grows stronger the farther away a cell is from the explosion's origin. Formally, the damage a cell (x,y)(x,y) receives from a single explosion at (i,j)(i,j) is defined as max⁡(∣x−i∣,∣y−j∣).\max(|x-i|, |y-j|). If there are multiple explosions, the total damage to (x,y)(x,y) is the sum of contributions from all explosions.

Before Utsuho even unleashed her power, Reimu used her foresight. She managed to foresee the total damage that each cell on the grid would receive after all explosions. With this knowledge, she hoped to pinpoint the exact locations of Utsuho's explosions and stop them in advance. However, her vision revealed only the damage values and not the precise origin of the blasts.

Given the total damage values of all cells, find any valid set of explosion locations that could explain Reimu's foresight.

입력

The first line contains a single integer NN.

The next N+2N+2 lines each contain N+2N+2 non-negative integers separated by spaces. The jj-th integer on the next ii-th line represents the total damage value of cell (i−1,j−1)(i-1,j-1), where rows and columns are numbered from 00 to N+1N+1 as described above.

출력

Over a total of NN lines, output NN integers per line, separated by spaces. Each integer must be either 00 or 11. If the integer in row ii and column jj is 11, an explosion is scheduled to occur at cell (i−1,j−1)(i-1,j-1). If it is 00, no explosion is scheduled at cell (i−1,j−1)(i-1,j-1).

If multiple possible explosion scenarios exist, outputing just one is sufficient. At least one possible explosion scenario is guaranteed to exist.

제한

  • 1≤N≤1,0001\le N\le 1\\,000

예제1

  1. 예제 1

    입력
    3
    2 2 2 2 2
    2 1 1 1 2
    2 1 0 1 2
    2 1 1 1 2
    2 2 2 2 2
    
    예상 출력
    0 0 0
    0 1 0
    0 0 0