#C3834. Cityscape Redesign
Cityscape Redesign
Cityscape Redesign
You are given a grid with n rows and m columns representing the heights of buildings in a city. The task is to redesign the city such that in the resulting grid, the height values are strictly increasing along each row and each column. In other words, for every row i and every column index j (with appropriate indices), the following conditions must be satisfied:
\[ \begin{aligned} &a_{i,j} < a_{i,j+1} \quad \text{for every } 1 \leq j < m,\\ & a_{i,j} < a_{i+1,j} \quad \text{for every } 1 \leq i < n. \end{aligned} \]
You are allowed to increase the height values but not decrease them. Your goal is to determine the final configuration of the city grid that meets the conditions.
inputFormat
The first line of the input contains two integers n
and m
(the number of rows and columns, respectively). This is followed by n
lines, each containing m
integers representing the initial heights of the buildings in the grid.
outputFormat
Output the redesigned grid in n
lines. Each line should contain m
space-separated integers, representing the heights of the buildings after the redesign. The grid must satisfy that every row is strictly increasing from left to right and every column is strictly increasing from top to bottom.
3 3
1 2 3
2 3 4
3 4 5
1 2 3
2 3 4
3 4 5
</p>