2022 G.W. Coding Contest 1 S1: Semimagic Squares:

Magic squares are grids with the numbers in each column, each row, and each corner-to-corner diagonal adding up to the same total.

However, a semi-magic square is a magic square, but with any diagonal adding up to a different sum.

Given the length and width \(N\) of a grid, and the grid of numbers, print "yes" if the square is semi-magic, and print "no" if it is not.


TIME CONSTRAINT: 1s

Sample Input:

4
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1

Sample Output:

no

Submit Solution

Problem author: Vincent