fork(11) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. ios::sync_with_stdio(false);
  7. int n;
  8. cin >> n;
  9. for (int i = 0; i < n; i++)
  10. {
  11. int counter = 0, x;
  12. for (int j = 0; j < n; j++)
  13. {
  14. cin >> x;
  15. if (x)
  16. counter += (i == j ? 2 : 1);
  17. }
  18. cout << counter << " ";
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0s 3456KB
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