Printing patterns
/

## Algorithms, Breadth First Search, Graphs, Implementation, Matrix

Problem
Editorial
Analytics

You are required to form a matrix of size $r\times c$ where $r$ is the number of rows and $c$ is the number of columns. You are required to form the waves of numbers around the provided center, $(C_i,\ C_j)$ (0-based indexing).

Example:

• Size of the matrix: $r = 9$ and $c = 9$
• Center coordinates: $C_i = 4$ and $C_j = 4$ (0 based indexing)
• Pattern:

4 4 4 4 4 4 4 4 4
4 3 3 3 3 3 3 3 4
4 3 2 2 2 2 2 3 4
4 3 2 1 1 1 2 3 4
4 3 2 1 0 1 2 3 4
4 3 2 1 1 1 2 3 4
4 3 2 2 2 2 2 3 4
4 3 3 3 3 3 3 3 4
4 4 4 4 4 4 4 4 4

You are given the values of $r,\ c,\ C_i,\ C_j$ (the values of $C_i$ and $C_j$ is 0-based indexed). Your task is to print the provided pattern.

Input format

The first line contains four integers $r$, $c$, $C_i$, and $C_j$ denoting the number of rows, number of columns, $x$ coordinate of center, and $y$ coordinate of center.

Output format

Print the pattern for the provided input.

Constraints

$1 \le r \le 1e3\\ 1 \le c \le 1e3\\ 0 \le C_i < r\\ 0 \le C_j < c$

SAMPLE INPUT
10 10 5 5

SAMPLE OUTPUT
5 5 5 5 5 5 5 5 5 5
5 4 4 4 4 4 4 4 4 4
5 4 3 3 3 3 3 3 3 4
5 4 3 2 2 2 2 2 3 4
5 4 3 2 1 1 1 2 3 4
5 4 3 2 1 0 1 2 3 4
5 4 3 2 1 1 1 2 3 4
5 4 3 2 2 2 2 2 3 4
5 4 3 3 3 3 3 3 3 4
5 4 4 4 4 4 4 4 4 4

Explanation

Given input have shown output.

Time Limit: 2.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

## This Problem was Asked in

Initializing Code Editor...