#C10690. Symmetric Grid Pattern
Symmetric Grid Pattern
Symmetric Grid Pattern
You are given a grid with n rows and m columns, consisting of characters. Your task is to determine if the grid is symmetric about its horizontal central axis.
A grid is defined as symmetric if for every row i (0-indexed), the row at index i is identical to the row at index n-1-i. In mathematical notation, the grid is symmetric if for all \( i \) such that \( 0 \le i < \lfloor\frac{n}{2}\rfloor \), \[ grid[i] = grid[n-1-i]. \]
If the condition holds, output "YES"; otherwise, output "NO".
inputFormat
The first line contains two integers n and m separated by space (n is the number of rows and m is the number of columns).
The next n lines each contain a string of length m, representing a row of the grid.
outputFormat
Output a single line containing either "YES" if the grid is symmetric about its horizontal central axis, or "NO" otherwise.
## sample4 3
.#.
###
###
.#.
YES