Earthquake

0

0 votes
Hard
Problem

Team Codex has been given the task of displaying the intensity values of an earthquake that occurred on an island.The entire island can be considered as a grid of nxn size. It is known that the intensity of the earthquake decreases by 1 unit as we go away from the epicenter.If the grid size, location of the epicenter and the intensity of the earthquake are given as input, then help Codex print the intensities at all the locations of the island(grid).

Input format:

First line contains an integer, n which is the size of the square island(grid).
Second line contains two space separated integers i and j, denoting the row and column of the location of the epicenter in the grid.
Third line contains an integer m, which is the magnitude/intensity of the earthquake at the epicenter.

Output format:

The grid with the intensity values at all the locations.

Constraints:

1<=n<=100

For example:

Input:

5

2 2

3

Output:

1 1 1 1 1

1 2 2 2 1

1 2 3 2 1

1 2 2 2 1

1 1 1 1 1

Time Limit: 4
Memory Limit: 256
Source Limit:
Explanation

Since the epicenter of the earthquake is at (2,2) and the intensity is 3, the value at the position (2,2) is 3. As we move away from the epicenter the intensity decreases by 1 unit, so the values of the next level cells are 2 and 1 respectively.

Editor Image

?