Check whether an N \times N matrix is an Identity matrix (1s on the main diagonal, 0s everywhere else).
Difficulty: Hard
Phase: 6 · Mixed Logical Challenges
XP Reward: 30 XP
Topics: Mixed Logical Challenges, Hard
Supported Languages: Python, JavaScript, C, C++, Java
Problem Description
Given N followed by N x N matrix, check whether it is an Identity matrix (1s on main diagonal, 0s elsewhere). Print 'Yes' or 'No'. Input Format: Read input from standard input (stdin). Output Format: Print the result to standard output (stdout).
Constraints
- -10^9 <= N <= 10^9
Examples
Example 1
Input: 3 1 0 0 0 1 0 0 0 1
Output: Yes
Explanation: Sample execution for input 3 1 0 0 0 1 0 0 0 1