fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {Scanner sc=new Scanner(System.in);int sugg=0;
  12. int n=sc.nextInt();int[][] f=new int[n][n];sc.nextLine();
  13. for(int i=0;i<n;i++)
  14. {String s=sc.nextLine();
  15. for(int j=0;j<n;j++)
  16. { if(i!=j)
  17. f[i][j]=Character.getNumericValue(s.charAt(j));
  18. else
  19. f[i][j]=0;
  20. }}
  21. for(int i=0;i<n;i++)
  22. {int c=0;
  23. for(int j=0;j<n;j++)
  24. {if(f[j][i]==0)
  25. c++;
  26. }if(c<n)
  27. sugg=c-1+sugg;
  28. }System.out.println(sugg);
  29. }
  30. }
Success #stdin #stdout 0.07s 2184192KB
stdin
4
0111
1000
1000
1000
stdout
6