fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Main
  6. {
  7. static PrintWriter out = new PrintWriter(System.out);
  8. static int nextInt() throws IOException {
  9. in.nextToken();
  10. return (int)in.nval;
  11. }
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. int n = nextInt();
  15. for (int i = 0; i < n; i++) {
  16. int counter = 0, x;
  17. for (int j = 0; j < n; j++) {
  18. x = nextInt();
  19. if (x > 0) counter += (i == j ? 2 : 1);
  20. }
  21. out.print (counter + " ");
  22. out.flush();
  23. }
  24. }
  25. }
Success #stdin #stdout 0.04s 2184192KB
stdin
5
1 0 0 0 1
0 1 0 1 0
0 0 1 0 0
0 0 1 0 0
0 0 1 0 0
stdout
3 3 2 1 1