Advertisement
bogolyubskiyalexey

Moscow QF 2017 G

Oct 22nd, 2017
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. const int SIZE = 500 + 10;
  6.  
  7. using lint = long long;
  8.  
  9. int N, M;
  10. lint row[SIZE], col[SIZE];
  11. int r[SIZE][SIZE], c[SIZE][SIZE];
  12.  
  13.  
  14.  
  15. int main() {
  16.     scanf("%d%d",&N,&M);
  17.     for(int i = 0; i < N; ++i) {
  18.         for (int j = 0; j < M; ++j) {
  19.             scanf("%d%d",&r[i][j], &c[i][j]);
  20.             row[i] += c[i][j];
  21.             col[j] += r[i][j];
  22.         }
  23.     }
  24.     for (int i = 0; i < N; ++i) {
  25.         if (row[i]) {
  26.             printf("No\n");
  27.             return 0;
  28.         }
  29.     }
  30.     for (int i = 0; i < M; ++i) {
  31.         if (col[i]) {
  32.             printf("No\n");
  33.             return 0;
  34.         }
  35.     }
  36.     printf("Yes\n");
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement