Roy and Symmetric Logos
Practice
4 (124 votes)
Ad Hoc
Basic programming
Easy
Geometry
Implementation
Problem
79% Success 17367 Attempts 20 Points 5s Time Limit 256MB Memory 1024 KB Max Code

Roy likes Symmetric Logos.

How to check whether a logo is symmetric?
Align the center of logo with the origin of Cartesian plane. Now if the colored pixels of the logo are symmetric about both X-axis and Y-axis, then the logo is symmetric.

You are given a binary matrix of size N x N which represents the pixels of a logo.
1 indicates that the pixel is colored and 0 indicates no color.

For instance: Take a 5x5 matrix as follows:

01110
01010
10001
01010
01110

Graphically it is represented as follows:

enter image description here

Observe that it is symmetric about both X-axis and Y-axis.

Let's take another example of 5x5 matrix:

00100
01010
10001
01010
01110

Graphically it is represented as follows:

enter image description here

Now this logo is symmetric about Y-axis but it is not symmetric about X-axis.

Your task is to output YES if the logo is symmetric else output NO.

Input:
First line contains T - number of test cases.
T test cases follow.
First line of each test case contains the N - size of matrix.
Next N lines contains binary strings of length N.

Output:
Print YES or NO in a new line for each test case

Constraints:
1 ≤ T ≤ 10
2 ≤ N ≤ 32

Note: There will always be atleast 1 colored pixel in input data.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
42 votes
Tags:
ArraysData StructuresEasyMulti-dimensional
Points:20
3 votes
Tags:
MathematicsSetEasyMathamatics
Points:20
18 votes
Tags:
ApprovedData StructuresEasy