-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path1360E.cpp
More file actions
45 lines (39 loc) · 991 Bytes
/
1360E.cpp
File metadata and controls
45 lines (39 loc) · 991 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
38
39
40
41
42
43
44
45
//#define DEBUG
#define MAXN 2000000000
#define ll long long int
#include <bits/stdc++.h>
using namespace std;
int main() {
#ifdef DEBUG
freopen("in.in", "r", stdin);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
int t ;
cin >> t ;
while (t--) {
int n;
cin >> n;
vector<vector<bool >> v(n, vector<bool >(n, false));
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
char a;
cin >> a;
if (a=='1') v[i][j] = true;
}
}
bool flag = true;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
// right and down
if (j + 1 < n && i + 1 < n && v[i][j]){
flag &= (v[i][j+1] | v[i+1][j]);
}
}
}
//cout << n << endl;
if (flag) cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}