結果
問題 | No.179 塗り分け |
ユーザー |
![]() |
提出日時 | 2017-08-05 13:04:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 145 ms / 3,000 ms |
コード長 | 1,487 bytes |
コンパイル時間 | 1,679 ms |
コンパイル使用メモリ | 168,624 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 14:43:51 |
合計ジャッジ時間 | 4,204 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 40 |
ソースコード
#include <bits/stdc++.h> using namespace std; const string yes = "YES"; const string no = "NO"; const int MAX = 55; int h, w; char S[MAX][MAX]; bool vis[MAX][MAX]; inline bool in(const int hh, const int ww) { return 0 <= hh && hh < h && 0 <= ww && ww < w; } int main() { scanf("%d%d", &h, &w); { bool valid = false; for (int i = 0; i < h; i++) { scanf("%s", S[i]); for (int j = 0; j < w; j++) { valid |= S[i][j] == '#'; } } if (!valid) { cout << no << endl; return 0; } } for (int i = -h; i <= h; i++) { for (int j = -w; j <= w; j++) { if (i == 0 && j == 0) { continue; } bool ok = true; memset(vis, false, sizeof(vis)); for (int k = 0; k < h; k++) { for (int l = 0; l < w; l++) { if (S[k][l] == '#' && !vis[k][l]) { if (!in(k + i, l + j) || S[k + i][l + j] == '.' || vis[k + i][l + j]) { ok = false; } else { vis[k + i][l + j] = true; } } } } if (ok) { //cerr << i << " " << j << endl; cout << yes << endl; return 0; } } } cout << no << endl; return 0; }