CF 1360E-Polygon
如果一个 1 不是在最右边或最下边,则一定有一个 1 在他的紧邻着的下边或右边,否则不合法。
太妙了。
#include <iostream>
using namespace std;
const int N = 1e2 + 10;
int T, n;
char a[N][N];
int main()
{
cin >> T;
while (T -- )
{
cin >> n;
for (int i = 1; i <= n; i ++ )
{
for (int j = 1; j <= n; j ++ )
{
cin >> a[i][j];
}
}
int flag = 1;
for (int i = 1; i <= n; i ++ )
{
for (int j = 1; j <= n; j ++ )
{
if (a[i][j] == '1')
{
if (i == n || j == n) continue;
if (a[i + 1][j] == '1' || a[i][j + 1] == '1') continue;
flag = 0;
}
}
}
if (flag == 1) cout << "YES\n";
else cout << "NO\n";
}
return 0;
}
标签:1300,Polygon,int,cin,CF,1360E
From: https://www.cnblogs.com/bzdydscjgw/p/17330799.html