#K59087. Find Blank Subgrids
Find Blank Subgrids
Find Blank Subgrids
You are given a grid of size \(n \times m\). Your task is to find all possible rectangular subgrids. A subgrid is defined by two pairs of coordinates: the top-left corner \((r_1, c_1)\) and the bottom-right corner \((r_2, c_2)\), where \(0 \le r_1 \le r_2 < n\) and \(0 \le c_1 \le c_2 < m\).
Your program should output each subgrid coordinate on a separate line in the following format:
(r1, c1) (r2, c2)
For example, for a \(3 \times 3\) grid, the subgrid (0, 0) (1, 1)
represents the rectangular block spanning from row 0, column 0 to row 1, column 1.
The output order should follow a natural lexicographical order: first by \(r_1\), then \(c_1\), then \(r_2\), and finally \(c_2\).
inputFormat
Input is read from standard input. The first line contains two integers \(n\) and \(m\) separated by a space, representing the number of rows and columns respectively.
outputFormat
Output all possible subgrids on separate lines. Each line must display two coordinate pairs in the format: (r1, c1) (r2, c2)
.
1 1
(0, 0) (0, 0)
</p>