結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-18 20:40:49 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 95 ms / 3,000 ms |
| コード長 | 1,080 bytes |
| コンパイル時間 | 2,220 ms |
| コンパイル使用メモリ | 196,908 KB |
| 最終ジャッジ日時 | 2025-01-13 03:27:31 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()
const double PI = acos(-1);
bool solve(vector<string> bd) {
int h = bd.size(), w = bd[0].size();
int target = 0;
REP (i, h) REP (j, w) target += bd[i][j] == '#';
if (!target)
return false;
for (int y = 0; y < h; y++) {
for (int x = 1-w; x < w; x++) {
if (!x && !y) continue;
vector<string> tmp = bd;
int cnt = 0;
REP (i, h) REP (j, w) {
if (tmp[i][j] != '#') continue;
if (i+y < h && j+x >= 0 && j+x < w && tmp[i+y][j+x] == '#') {
tmp[i][j] = tmp[i+y][j+x] = '.';
cnt += 2;
}
}
if (cnt == target)
return true;
}
}
return false;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int h, w;
cin >> h >> w;
vector<string> bd(h);
REP (i, h) cin >> bd[i];
if (solve(bd))
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}