← 返回 meta 的题目列表Set Matrix Zeroes (Zero out rows and columns containing a 0)
类型:online_judge
Problem: Set Matrix Zeroes
Given an m x n integer matrix matrix. If an element matrix[i][j] == 0, set the entire i-th row and j-th column to 0.
Return/print the resulting matrix.
Input
Line 1: two integers m n.
Next m lines: n integers each.
Output
Print m lines, each with n integers, the matrix after zeroing.
Constraints
1 <= m, n <= 200
-1e9 <= matrix[i][j] <= 1e9
Example
Input:
3 3
1 1 1
1 0 1
1 1 1
Output:
1 0 1
0 0 0
1 0 1
Example
Input
3 3
1 1 1
1 0 1
1 1 1
Output
1 0 1
0 0 0
1 0 1