main.cpp 465 B

1234567891011121314151617181920212223
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. int T;
  5. while (cin >> T) {
  6. for (int i = 0; i < T; i++) {
  7. int N, M;
  8. cin >> N >> M;
  9. int grid = 0;
  10. int count = 0;
  11. for (int j = 0; j < N * M; j++) {
  12. cin >> grid;
  13. if (grid == 1) {
  14. count++;
  15. }
  16. }
  17. cout << count << endl;
  18. }
  19. }
  20. return 0;
  21. }