-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2090b.cpp
More file actions
37 lines (35 loc) · 791 Bytes
/
2090b.cpp
File metadata and controls
37 lines (35 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <bits/stdc++.h>
using namespace std;
#define NO cout<<"NO\n"
#define YES cout<<"YES\n"
#define F first
#define S second
#define cases int _; cin >> _; while(_--)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef set<int> si;
void solve() {
int a,b; cin >> a >> b;
char C[a+1][b+1]; memset(C, '1', sizeof(C));
for(int i = 1; i < a+1; i++) {
for(int j = 1; j < b+1; j++) {
cin >> C[i][j];
}
}
for(int i = 1; i < a+1; i++) {
for(int j = 1; j < b+1; j++) {
if(C[i][j] == '1') {
if(C[i-1][j] == '0' && C[i][j-1] == '0') {NO; return;}
}
}
}
YES;
}
int main() {
cases {
solve();
}
return 0;
}