fork download
  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 IOException
  8. {
  9. Scanner in = new Scanner(System.in);
  10. int n = in.nextInt();
  11. int a[][] = new int[n][n];
  12. for(int i = 0; i < n; i++) {
  13. for(int j = 0; j < n; j++) {
  14. a[i][j] = in.nextInt();
  15. if ((i == j) && (a[i][j] == 1)) {
  16. System.out.print("NO");
  17. return;
  18. }
  19. }
  20. }
  21. for(int i = 0; i < n; i++) {
  22. for(int j = 0; j < n; j++) {
  23. if (a[i][j] != a[j][i]) {
  24. System.out.print("NO");
  25. return;
  26. }
  27. }
  28. }
  29. System.out.print("YES");
  30. }
  31. }
Success #stdin #stdout 0.07s 2184192KB
stdin
4
0 0 1 1
0 0 0 1
1 0 0 0
1 1 0 0
stdout
YES