fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Main
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Scanner in = new Scanner(System.in);
  10. int n = in.nextInt();
  11. int[][] x = new int[n][n];
  12. for(int i = 0; i < n; i++) {
  13. for(int j = 0; j < n; j++) {
  14. x[i][j] = in.nextInt();
  15. }
  16. }
  17. int roads = 0;
  18. for(int i = 0; i < n; i++) {
  19. for(int j = i; j < n; j++) {
  20. if(x[i][j] == 1) roads++;
  21. }
  22. }
  23. System.out.print(roads);
  24. }
  25. }
  26.  
Runtime error #stdin #stdout #stderr 0.06s 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:10)