시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 2048 MB71114.286%

문제

A city consists of a rectangular $N \times M$ grid of blocks. Each block $(i, j)$ has some unknown power consumption $A_{i, j}$. Some of the city blocks house power stations, while some might have no buildings in them at all, so it's possible that $A_{i, j}$ is positive, negative or even zero.

Previously the city lived in an era of almost unlimited free energy thanks to cheap solar power, but after an incident involving the collisions of millions of Internet-providing satellites resulted in only half of all sunlight being able to reach Earth, your power plants have reverted to more expensive energy sources. As a result, the energy company must start billing its customers for their power usage. Unfortunately nobody bothered to install proper electricity meters.

While you lack measurements of block-level power usage, the company is able to use the power consumption on a row and column basis in the city to infer, for each block, a number $$C_{i, j} = \left| \sum_{k=1}^N A_{k, j} - \sum_{k=1}^M A_{i, k} \right| \text{,}$$ that is, the difference in the total power consumption of all blocks on the $i$'th row compared to the $j$'th column for each $i, j$.

Using these numbers, can you reconstruct the original power consumptions $A_{i, j}$?

입력

The first line contains the dimensions of the city $N$ and $M$ ($1 \le N, M \le 1\,000$). This is followed by $N$ lines each containing $M$ integers, where the $j$'th number on the $i$'th line equals $C_{i, j}$ ($0 \le C_{i, j} \le 1\,000$).

The input has been constructed in such a way that a solution always exists.

출력

Output $N$ lines each containing $M$ integers, where the $j$'th number on the $i$'th line equals $A_{i, j}$. If there are several possible choices of $A_{i, j}$ that are valid, you may output any of them.

The numbers $A_{i, j}$ must satisfy $-2147483648 \leq A_{i, j} \leq 2147483647$, otherwise you will get wrong answer.

서브태스크

번호배점제한
18

$N,M,C_{i,j} \leq 3$

25

$N,M,C_{i,j} \leq 6$

311

$N = 1$

46

$N,M \geq 2$ and all numbers $C_{i,j}$ are the same

515

$N,M \geq 2$ and all numbers $C_{i,j}$ are different

65

$C_{i,j} \leq 1$

715

$N = M$

825

$N,M,C_{i,j} \leq 100$

910

No further constraints

예제 입력 1

2 3
3 4 1
6 7 2

예제 출력 1

1 2 6
5 3 4

예제 입력 2

3 4
0 0 0 0
0 0 0 0
0 0 0 0

예제 출력 2

0 0 0 0
0 0 0 0
0 0 0 0

출처

Olympiad > Nordic Olympiad in Informatics > 2022 B번

  • 문제를 만든 사람: Nils Gustafsson

채점 및 기타 정보

  • 예제는 채점하지 않는다.
  • 이 문제의 채점 우선 순위는 2이다.