#K94987. Toeplitz Matrix Checker
Toeplitz Matrix Checker
Toeplitz Matrix Checker
Given an integer matrix of size \(r \times c\), determine whether the matrix is a Toeplitz matrix. A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element, i.e., for every valid index \(i, j\) with \(i > 0\) and \(j > 0\), the condition \(a_{ij} = a_{i-1,j-1}\) holds.
Your task is to implement a program that reads the matrix from the standard input and prints True
if the matrix is a Toeplitz matrix or False
otherwise.
Example:
Input: 3 4 1 2 3 4 5 1 2 3 9 5 1 2</p>Output: True
inputFormat
The first line of input contains two integers \(r\) and \(c\) representing the number of rows and columns respectively. This is followed by \(r\) lines, each containing \(c\) integers separated by spaces, representing the matrix.
outputFormat
Output a single line with either True
or False
indicating whether the matrix is a Toeplitz matrix.
3 4
1 2 3 4
5 1 2 3
9 5 1 2
True