From 1a7bf3af43759770eb196238e8f3f09155d0454c Mon Sep 17 00:00:00 2001 From: Baoshuo Ren Date: Sat, 26 Feb 2022 21:08:27 +0800 Subject: [PATCH] C - Connect 6 https://atcoder.jp/contests/abc241/submissions/29697743 --- AtCoder/ABC241/C/C.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 AtCoder/ABC241/C/C.cpp diff --git a/AtCoder/ABC241/C/C.cpp b/AtCoder/ABC241/C/C.cpp new file mode 100644 index 00000000..9ae38aec --- /dev/null +++ b/AtCoder/ABC241/C/C.cpp @@ -0,0 +1,61 @@ +#include +#include + +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; +}