#C11870. 180-Degree Rotated Garden Symmetry

    ID: 41234 Type: Default 1000ms 256MiB

180-Degree Rotated Garden Symmetry

180-Degree Rotated Garden Symmetry

You are given a garden represented as an N × M matrix of integers. Each element in the matrix indicates the type of flower at that cell. The garden is said to be symmetric after a 180-degree rotation if for every cell at position \( (i,j) \) the following condition holds:

\( garden[i][j] = garden[N-1-i][M-1-j] \)

Indices are 0-indexed. Your task is to determine whether the garden remains the same after a 180-degree rotation.

Input Format

The first line contains two space-separated integers \( N \) and \( M \), representing the number of rows and columns of the garden, respectively. This is followed by \( N \) lines, each containing \( M \) space-separated integers representing the garden matrix.

Output Format

Print a single line: YES if the garden is symmetric after a 180-degree rotation, or NO otherwise.

inputFormat

Standard input (stdin) will contain the following:

  • The first line contains two integers \( N \) and \( M \).
  • The next \( N \) lines each contain \( M \) space-separated integers representing the garden matrix.

outputFormat

Standard output (stdout) should contain a single word: YES if the garden is symmetric after a 180-degree rotation, and NO otherwise.

## sample
3 3
1 2 1
3 4 3
1 2 1
YES

</p>