#K83247. DiagonSquare Validator
DiagonSquare Validator
DiagonSquare Validator
The problem is to determine whether a given square grid of integers constitutes a DiagonSquare. A grid is considered a DiagonSquare if the sum of the primary diagonal is equal to the sum of the secondary diagonal. In mathematical terms, for an n × n grid \(A\), this condition is:
[ \sum_{i=0}^{n-1} A_{i,i} = \sum_{i=0}^{n-1} A_{i,n-i-1} ]
Your task is to read the grid from standard input and output YES if the grid is a DiagonSquare and NO otherwise.
inputFormat
The input is read from standard input. The first line contains a single integer n representing the size of the grid. This is followed by n lines, each containing n space-separated integers representing one row of the grid.
outputFormat
Output a single line to standard output with either YES if the grid is a DiagonSquare or NO if it is not.
## sample3
2 9 2
4 2 4
6 9 6
YES