#K52207. Draw a Rectangle on a Canvas
Draw a Rectangle on a Canvas
Draw a Rectangle on a Canvas
In this problem, you are given the dimensions of a 2D canvas and the coordinates of the top-left and bottom-right corners of a rectangle. Your task is to mark the rectangle on the canvas by assigning the value 1 to all cells inside the rectangle. Cells outside the rectangle should be 0. If the provided rectangle coordinates are invalid (i.e. the top-left corner is not above and to the left of the bottom-right corner, or any coordinate is out of the canvas bounds), then the canvas should remain unmodified.
More formally, let (M) and (N) be the number of rows and columns of the canvas, respectively. You are given two pairs of integers ((x_1, y_1)) and ((x_2, y_2)). The rectangle is valid if and only if (0 \le x_1 \le x_2 < M) and (0 \le y_1 \le y_2 < N). For a valid rectangle, every cell in rows from (x_1) to (x_2) and columns from (y_1) to (y_2) should be set to 1; otherwise, leave every cell as 0.
inputFormat
The input is read from standard input (stdin) and consists of three lines:
- The first line contains two integers (M) and (N) separated by a space, representing the number of rows and columns of the canvas respectively.
- The second line contains two integers (x_1) and (y_1) separated by a space, indicating the coordinates of the top-left corner of the rectangle.
- The third line contains two integers (x_2) and (y_2) separated by a space, indicating the coordinates of the bottom-right corner of the rectangle.
outputFormat
Output the final state of the canvas to standard output (stdout). The canvas should be printed as (M) lines, each line containing (N) integers separated by a single space. There should be no extra spaces at the end of a line.## sample
5 7
1 2
3 5
0 0 0 0 0 0 0
0 0 1 1 1 1 0
0 0 1 1 1 1 0
0 0 1 1 1 1 0
0 0 0 0 0 0 0
</p>