Advertisement
unknown_0711

Untitled

Oct 31st, 2022
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. public class Main
  6. {
  7. public static void main (String[]args) throws java.lang.Exception
  8. {
  9. Scanner sc = new Scanner (System.in);
  10. int t = sc.nextInt ();
  11. while (t-- > 0)
  12. {
  13. int n = sc.nextInt ();
  14. int arr[][] = new int[n][n];
  15. for (int i = 0; i < n; i++)
  16. {
  17. for (int j = 0; j < n; j++)
  18. {
  19. arr[i][j] = sc.nextInt ();
  20. }}
  21. boolean flag = true;
  22. for (int i = 0; i < n; i++)
  23. {
  24. for (int j = 0; j < n; j++)
  25. {
  26. if (i == j || ((i + j) - (n - 1)) == 0)
  27. {
  28. if (arr[i][j] == 0)
  29. {
  30. // System.out.println (i+" "+j);
  31. flag = false;
  32. }
  33. }
  34. else
  35. {
  36. if (arr[i][j] != 0)
  37. {
  38. // System.out.println (i+" "+j);
  39. flag = false;
  40. }
  41. }
  42. }
  43. }
  44. if (flag == true)
  45. {
  46. System.out.println ("1");
  47. }
  48. else
  49. {
  50. System.out.println ("0");
  51. }
  52. }
  53. }
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement