0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 22:48:48 +00:00

C - Connect 6

https://atcoder.jp/contests/abc241/submissions/29697743
This commit is contained in:
Baoshuo Ren 2022-02-26 21:08:27 +08:00
parent 9a6693b2bd
commit 1a7bf3af43
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

61
AtCoder/ABC241/C/C.cpp Normal file
View File

@ -0,0 +1,61 @@
#include <iostream>
#include <string>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1005;
int n;
std::string g[N];
bool check(int x, int y) {
if (x + 5 < n) {
int cnt = 0;
for (int i = x; i <= x + 5; i++) {
if (g[i][y] == '.') cnt++;
}
if (cnt <= 2) return true;
}
if (y + 5 < n) {
int cnt = 0;
for (int i = y; i <= y + 5; i++) {
if (g[x][i] == '.') cnt++;
}
if (cnt <= 2) return true;
}
if (x + 5 < n && y + 5 < n) {
int cnt = 0;
for (int i = 0; i <= 5; i++) {
if (g[x + i][y + i] == '.') cnt++;
}
if (cnt <= 2) return true;
}
if (x + 5 < n && y - 5 >= 0) {
int cnt = 0;
for (int i = 0; i <= 5; i++) {
if (g[x + i][y - i] == '.') cnt++;
}
if (cnt <= 2) return true;
}
return false;
}
int main() {
std::ios::sync_with_stdio(false);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> g[i];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (check(i, j)) {
cout << "Yes" << endl;
exit(0);
}
}
}
cout << "No" << endl;
return 0;
}