Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.lang.*;
- import java.io.*;
- public class Main
- {
- public static void main (String[]args) throws java.lang.Exception
- {
- Scanner sc = new Scanner (System.in);
- int t = sc.nextInt ();
- while (t-- > 0)
- {
- int n = sc.nextInt ();
- int arr[][] = new int[n][n];
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- arr[i][j] = sc.nextInt ();
- }}
- boolean flag = true;
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- if (i == j || ((i + j) - (n - 1)) == 0)
- {
- if (arr[i][j] == 0)
- {
- // System.out.println (i+" "+j);
- flag = false;
- }
- }
- else
- {
- if (arr[i][j] != 0)
- {
- // System.out.println (i+" "+j);
- flag = false;
- }
- }
- }
- }
- if (flag == true)
- {
- System.out.println ("1");
- }
- else
- {
- System.out.println ("0");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement