fork download
  1. import java.util.*;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int n = sc.nextInt();
  6. String answer = "YES";
  7. short[][] graph = new short [n][n];
  8. for (int i = 0; i < n; i++) {
  9. for( int j = 0; j < n; j++) {
  10. graph[i][j] = sc.nextShort();
  11. }
  12. }
  13. for(int i = 0; i < n; i++){
  14. for(int j = 0; j < n; j++){
  15. if (graph[i][j] == 1){
  16. for (int z = 0; z < n; z++){
  17. if (graph[j][z] == 1 && graph[i][z] == 0) {
  18. answer = "NO";
  19. break;
  20. }
  21. }
  22. }
  23. }
  24. }
  25. System.out.print(answer);
  26. }
  27.  
  28. }
  29.  
Runtime error #stdin #stdout #stderr 0.07s 2184192KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.util.NoSuchElementException
	at java.util.Scanner.throwFor(Scanner.java:862)
	at java.util.Scanner.next(Scanner.java:1485)
	at java.util.Scanner.nextInt(Scanner.java:2117)
	at java.util.Scanner.nextInt(Scanner.java:2076)
	at Main.main(Main.java:5)