#C10933. Rectangular Region Checker
Rectangular Region Checker
Rectangular Region Checker
You are given a grid of integers consisting only of 0s and 1s. Your task is to determine whether there exists at least one rectangular region of size \(2 \times 2\) that is completely filled with 1s.
The grid is represented as \(n\) rows and \(m\) columns. A rectangular region is defined as a contiguous submatrix, and in this problem, you only need to check if there is any \(2 \times 2\) submatrix where every cell is 1.
If such a region exists, output "YES"; otherwise, output "NO". This is a typical grid search problem that can be solved by iterating over the pairs of adjacent rows and columns.
inputFormat
The first line contains two integers \(n\) and \(m\) (the number of rows and columns, respectively). Each of the next \(n\) lines contains \(m\) space-separated integers (either 0 or 1) representing a row of the grid.
outputFormat
Output a single line with either "YES" if there exists at least one \(2 \times 2\) submatrix filled with 1s, or "NO" otherwise.
## sample4 5
1 0 1 1 1
1 1 1 1 1
1 1 1 1 0
1 1 1 0 0
YES