結果
問題 | No.179 塗り分け |
ユーザー |
|
提出日時 | 2023-03-13 08:54:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 72 ms / 3,000 ms |
コード長 | 802 bytes |
コンパイル時間 | 1,782 ms |
コンパイル使用メモリ | 195,348 KB |
最終ジャッジ日時 | 2025-02-11 10:49:30 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 40 |
ソースコード
#include <bits/stdc++.h> using namespace std; const int N = 55; string s[N]; bool vis[N][N]; int main() { ios::sync_with_stdio(0); int n, m; cin >> n >> m; for(int i = 0; i < n; i ++) cin >> s[i]; bool f = 0; for(int t : {0, 1}) { for(int i = 0; i <= n; i ++) for(int j = 0; j <= m; j ++) if(i + j > 0) { bool t = 1; int cnt = 0; memset(vis, 0, sizeof vis); for(int x = 0; x < n; x ++) for(int y = 0; y < m; y ++) if(s[x][y] == '#' && !vis[x][y]) { vis[x][y] = 1; cnt ++; int tx = x + i, ty = y + j; if(tx >= 0 && tx < n && ty >= 0 && ty < m && s[tx][ty] == '#') { vis[tx][ty] = 1; } else { t = 0; } } f |= (t && cnt > 0); } reverse(s, s + n); } cout << (f ? "YES" : "NO") << '\n'; }