#C9528. Symmetric Central Tile
Symmetric Central Tile
Symmetric Central Tile
Given an N × N matrix representing a tile pattern, determine whether the matrix is symmetric under a 180° rotation, i.e. for every pair of indices i and j the following holds:
\( a[i][j] = a[N-1-i][N-1-j] \)
For even-sized matrices, an additional condition is imposed on the central 2×2 block: the top-left element must equal the bottom-right element and the top-right element must equal the bottom-left element.
If the above conditions are satisfied, output YES
; otherwise, output NO
.
inputFormat
The first line contains an integer N (the size of the matrix).
The next N lines each contain N space-separated integers representing the matrix rows.
outputFormat
Output a single line containing YES
if the matrix satisfies the symmetry conditions, otherwise output NO
.
3
1 2 1
2 3 2
1 2 1
YES