-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1360E - Polygon.cpp
67 lines (64 loc) · 1.36 KB
/
1360E - Polygon.cpp
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
using namespace std;
#define nn <<endl
#define ee <<" "
#define ll long long int
#define floi for(int i=0;i<n;i++)
#define floj for(int j=0;j<n;j++)
ll t, n, k;
int main()
{
cin >> t;
while (t--)
{
cin>> n;
bool x[n][n];
for (int i=0; i<n; i++)
{
for(int j=0;j<n;j++)
{
char l;
cin>> l;
if (l=='0')
x[i][j] = 0;
else
x[i][j] = 1;
}
}
bool flag = 1;
for (int i=0; i<n; i++)
{
for(int j=n-2;j>=0;j--)
{
if (x[i][j])
{
if (j==n-1 || x[i][j+1])
{
flag = 1;
}
else if (x[i+1][j] || i==n-1)
{
flag = 1;
}
else
{
flag = 0;
goto out;
}
}
}
}
out:
(flag)? cout<<"YES\n":cout<<"NO\n";
}
return 0;
}