~/algor $ cat problems/matritsa-nollarni-tarqatish
Spread the zeros
Medium
1000 ms
64 MB
46%
A matrix of size $n \times m$ is given. For every cell that holds $0$ in the original matrix, its whole row and its whole column become zero. (Only the original zeros count: zeros that appear along the way do not clear their own row and column.) Print the resulting matrix.
Input
The first line contains two positive integers $n$ and $m$.
Each of the next $n$ lines contains $m$ integers — the matrix.
Output
$n$ lines with $m$ integers each.
Note
$1 \le n, m \le 100$
$-1000 \le a_{i,j} \le 1000$
Examples
Input #1
3 4 1 2 3 4 5 0 7 8 9 10 11 0
Output #1
1 0 3 0 0 0 0 0 0 0 0 0
Input #2
2 2 1 2 3 4
Output #2
1 2 3 4