Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int SIZE = 500 + 10;
- using lint = long long;
- int N, M;
- lint row[SIZE], col[SIZE];
- int r[SIZE][SIZE], c[SIZE][SIZE];
- int main() {
- scanf("%d%d",&N,&M);
- for(int i = 0; i < N; ++i) {
- for (int j = 0; j < M; ++j) {
- scanf("%d%d",&r[i][j], &c[i][j]);
- row[i] += c[i][j];
- col[j] += r[i][j];
- }
- }
- for (int i = 0; i < N; ++i) {
- if (row[i]) {
- printf("No\n");
- return 0;
- }
- }
- for (int i = 0; i < M; ++i) {
- if (col[i]) {
- printf("No\n");
- return 0;
- }
- }
- printf("Yes\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement