結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-13 18:12:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,343 bytes |
| コンパイル時間 | 922 ms |
| コンパイル使用メモリ | 79,748 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-28 01:41:05 |
| 合計ジャッジ時間 | 2,507 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 34 WA * 6 |
ソースコード
// No.179 塗り分け
#include <iostream>
#include <vector>
using namespace std;
int main() {
int H, W;
cin >> H >> W;
vector<vector<char>> S(H, vector<char>(W));
int s = 0;
for (int i = 0; i < H; ++i) {
for (int j = 0; j < W; ++j) {
cin >> S[i][j];
if (S[i][j] == '#') ++s;
}
}
vector<vector<bool>> used(H, vector<bool>(W, false));
for (int dy = 0; dy < H; ++dy) {
for (int dx = 0; dx < W; ++dx) {
if (dy == 0 && dx == 0) continue;
used.assign(H, vector<bool>(W, false));
int painted = 0;
bool ng = false;
for (int xy = 0; xy < H * W; ++xy) {
int y = xy / W, x = xy % W;
if (S[y][x] == '.') continue;
if (used[y][x]) continue;
if (y + dy >= H || x + dx >= W) {
ng = true;
break;
}
if (S[y + dy][x + dx] == '.') {
ng = true;
break;
}
painted += 2;
used[y + dy][x + dx] = true;
}
if (ng) continue;
if (painted == s) {
cout << "YES" << endl;
return 0;
}
}
}
cout << "NO" << endl;
}