#K65267. Symmetric Matrix Check

    ID: 32160 Type: Default 1000ms 256MiB

Symmetric Matrix Check

Symmetric Matrix Check

Given an N×N matrix of characters, determine whether the matrix is symmetric with respect to its main diagonal. In mathematical terms, the matrix M is symmetric if for all valid indices \(i, j\) it holds that \(M[i,j] = M[j,i]\).

The matrix is provided as N strings, each containing exactly N characters. Your task is to output "YES" if the matrix is symmetric, or "NO" otherwise.

Note: The symmetry condition can be formally expressed as:

\[ M[i,j] = M[j,i] \quad \text{for all } 0 \leq i, j < N \]

inputFormat

The input is read from standard input (stdin) and is structured as follows:

  • The first line contains an integer N representing the size of the matrix.
  • The following N lines each contain a string of length N representing a row of the matrix.

outputFormat

The output should be written to standard output (stdout) and is a single line containing either "YES" if the matrix is symmetric with respect to its main diagonal, or "NO" otherwise.

## sample
3
a#c
#b#
c#b
YES