#P10644. [NordicOI 2022] 能源网格 Power Grid
[NordicOI 2022] 能源网格 Power Grid
Background
Translated from Nordic Olympiad in Informatics 2022 Power Grid。If you find that the SPJ is broken, please contact the problem porter qvq。
。Please do not abuse the judging of this problem.
Problem Description
There is a city consisting of an by grid, with a total of cells. The power consumption of cell is denoted by 。Here, can be positive, negative, or 。
For cell , define
$$C_{i, j} = \left| \sum _{k=1}^ N A_{k, j} - \sum _{k=1}^ M A_{i, k} \right|$$That is, the absolute value of the difference between the total power usage of a column and the total power usage of a row。
Given all , can you construct a valid set of ?
The testdata guarantees that at least one solution exists。
Input Format
The first line contains two positive integers , with meanings as described in the statement。
In the next lines, the -th number in line is , with meaning as described in the statement。
It is guaranteed that at least one solution exists。
Output Format
Output lines each with numbers, where the -th number in line is 。
If there are multiple solutions, output any one of them。
You need to ensure that 。
2 3
3 4 1
6 7 2
1 2 6
5 3 4
3 4
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
Hint
Constraints
- ;
- ;
- At least one solution is guaranteed。
Subtasks
| Subtask ID | Score | Constraints |
|---|---|---|
| ,all are the same | ||
| ,all are pairwise distinct | ||
| No additional constraints |
Translated by ChatGPT 5