#C2397. 2x2 Subgrid Sum Check
2x2 Subgrid Sum Check
2x2 Subgrid Sum Check
Given an \( n \times m \) grid of integers, your task is to determine whether there exists at least one 2x2 subgrid in the matrix. A 2x2 subgrid is defined as a contiguous block of 4 cells.
Note that for any 2x2 subgrid, the sum of its elements is always either even or odd. Therefore, if the grid has dimensions allowing at least one 2x2 subgrid (i.e. when \( n \ge 2 \) and \( m \ge 2 \)), the answer is YES
. Otherwise, if the grid is too small to contain a 2x2 subgrid, output NO
.
inputFormat
The input begins with two integers \( n \) and \( m \) separated by a space, representing the number of rows and columns in the grid respectively. This is followed by \( n \) lines, each containing \( m \) integers separated by spaces, representing the grid.
outputFormat
Output a single line containing YES
if there exists at least one 2x2 subgrid (i.e. when \( n \ge 2 \) and \( m \ge 2 \)); otherwise, output NO
.
3 3
1 2 3
4 5 6
7 8 9
YES