# Codeforces E. Polygon (思维 / 判断)

#include<bits/stdc++.h>
#define endl '\n'
#define null NULL
#define ll long long
#define int long long
#define pii pair<int, int>
#define lowbit(x) (x &(-x))
#define ls(x) x<<1
#define rs(x) (x<<1+1)
#define me(ar) memset(ar, 0, sizeof ar)
#define mem(ar,num) memset(ar, num, sizeof ar)
#define rp(i, n) for(int i = 0, i < n; i ++)
#define rep(i, a, n) for(int i = a; i <= n; i ++)
#define pre(i, n, a) for(int i = n; i >= a; i --)
#define IOS ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
const int way[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
using namespace std;
const int  inf = 0x7fffffff;
const double PI = acos(-1.0);
const double eps = 1e-6;
const ll   mod = 1e9 + 7;
const int  N = 55;

int t, n;
char a[N][N];

signed main()
{
IOS;

cin >> t;
while(t --){
cin >> n;
for(int i = 0; i < n; i ++) cin >> a[i];
int ok = 1;
for(int i = 0; i < n; i ++){
for(int j = 0; j < n; j ++){
if(a[i][j] == '1'){
if(j == n -1 || i == n - 1 || a[i][j + 1] == '1' || a[i + 1][j] == '1')
continue;
else {ok = 0; break;}
}
}
if(!ok) break;
}
cout << (ok ? "YES" : "NO") << endl;
}

return 0;
}


• 点赞
• 评论
• 分享
x

海报分享

扫一扫，分享海报

• 收藏
• 手机看

分享到微信朋友圈

x

扫一扫，手机阅读

• 打赏

打赏

S atur

你的鼓励将是我创作的最大动力

C币 余额
2C币 4C币 6C币 10C币 20C币 50C币
• 一键三连

点赞Mark关注该博主, 随时了解TA的最新博文

08-29 1356
07-10 501
08-05 714