309. Toeplitz Matrix
EasyMatrix
A matrix is Toeplitz if every top-left to bottom-right diagonal has equal elements. Print YES or NO.
Input format
Line 1: r c Next r lines: c integers
Output format
YES or NO
Example 1
Input
3 4 1 2 3 4 5 1 2 3 9 5 1 2
Output
YES
Example 2
Input
2 2 1 2 2 2
Output
NO
Constraints
1 ≤ r, c ≤ 500
Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.
Loading the MyLoginn IDE…