#K92152. Symmetric Matrix Checker
Symmetric Matrix Checker
Symmetric Matrix Checker
This problem requires you to determine if a given square matrix is symmetric, i.e. a matrix \(A\) is symmetric if \(A[i][j] = A[j][i]\) for all valid indices \(i\) and \(j\). You will be provided with an integer \(n\) which represents the size of the matrix (both rows and columns) followed by \(n\) rows, each containing \(n\) integers. Print YES
if the matrix is symmetric; otherwise, print NO
.
inputFormat
The input is read from stdin and structured as follows:
- The first line contains an integer \(n\), the size of the matrix.
- The next \(n\) lines contain \(n\) space-separated integers each, representing the rows of the matrix.
outputFormat
The output should be written to stdout. Print YES
if the matrix is symmetric; otherwise, print NO
.
1
5
YES