#K93137. Palindromic Rows in a Grid
Palindromic Rows in a Grid
Palindromic Rows in a Grid
In this problem, you are given a grid of characters with ( n ) rows and ( m ) columns. Your task is to determine whether every row of the grid is a palindrome, i.e., it reads the same forward and backward. A string ( s ) is palindromic if ( s_i = s_{|s|-i+1} ) for all valid indices. For each row, if it is a palindrome, then it satisfies the condition. If all rows are palindromic, print Yes; otherwise, print No.
inputFormat
The input is given via standard input and consists of the following:\n- The first line contains two integers ( n ) and ( m ) — the number of rows and the number of columns respectively.\n- Each of the next ( n ) lines contains a string of length ( m ) representing a row of the grid.
outputFormat
Output a single line to standard output containing either Yes if every row in the grid is a palindrome, or No otherwise.## sample
3 5
abxba
bcbcb
dzdzd
Yes