結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-04-06 01:11:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,250 bytes |
| コンパイル時間 | 646 ms |
| コンパイル使用メモリ | 66,244 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-02 13:40:44 |
| 合計ジャッジ時間 | 5,856 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 RE * 3 |
| other | AC * 13 RE * 27 |
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
vector<string> board;
int h, w;
bool check(int mx, int my) {
if (mx == 0 && my == 0) {
return false;
}
auto paint = board;
for (int i = -h; i < h; i++) {
for (int j = -w; j < w; j++) {
if (0 <= i + my && i + my < h && 0 <= j + mx && j + mx < w) {
if (paint[i][j] == '#') {
if (board[i][j] == board[i + my][j + mx]) {
paint[i][j] = 'A';
paint[i+my][j+mx] = 'B';
}
}
}
}
}
int na = 0, nb = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
switch (paint[i][j]) {
case 'A': na++; break;
case 'B': nb++; break;
case '#': return false;
default: break;
}
}
}
return (na == nb && na > 0);
}
int main() {
cin >> h >> w;
board.assign(h, "");
int n = 0;
for (int i = 0; i < h; i++) {
cin >> board[i];
n += count(board[i].begin(), board[i].end(), '#');
}
if (n % 2 == 1) {
cout << "NO" << endl;
return 0;
}
int half = n / 2;
for (int my = 0; my < h; my++) {
for (int mx = 0; mx < w; mx++) {
if (check(mx, my)) {
cout << "YES" << endl;
return 0;
}
}
}
cout << "NO" << endl;
return 0;
}