Check for disorientation
Problem
Given a square n×n matrix of zeros and ones, determine whether the given matrix can be an adjacency matrix of a simple undirected graph.
Input:
- the first line contains the number n (\(1<=n<=100\)) – matrix size;
- then the matrix itself is set - n rows of n numbers, each of which is equal to 0 or 1.
Output: print «YES» if the matrix given can be the adjacency matrix of a simple undirected graph, and « ;NO» otherwise.
Examples
| # |
Input |
Output |
| 1 |
5
0 0 1 0 0
0 0 1 0 1
1 1 0 0 0
0 0 0 0 0
0 1 0 0 0
|
YES |