結果
| 問題 | No.179 塗り分け |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-16 12:43:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 3,000 ms |
| コード長 | 1,343 bytes |
| コンパイル時間 | 876 ms |
| コンパイル使用メモリ | 76,784 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-23 14:45:18 |
| 合計ジャッジ時間 | 2,052 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <climits>
#include <tuple>
using namespace std;
int h, w;
bool check(const vector<char>& field, int mx, int my) {
bool red = false;
vector<char> f = field;
for(int y=0; y<h; y++) {
for(int x=0; x<w; x++) {
if(f[x+y*w] == '#') {
f[x+y*w] = 'R';
red = true;
int bx = x+mx;
int by = y+my;
if(!(0<=bx && bx<w && 0<=by && by<h)) return false;
if(f[bx+by*w] == '#') {
f[bx+by*w] = 'B';
} else {
return false;
}
}
}
}
return red;
}
int main() {
scanf("%d%d", &h, &w);
getchar();
auto field = vector<char>(w*h);
for(int y=0; y<h; y++) {
for(int x=0; x<w; x++) {
scanf("%c", &field[x + y*w]);
}
getchar();
}
for(int mx=-w+1; mx<w; mx++) {
for(int my=-h+1; my<h; my++) {
if(mx==0 && my==0) continue;
if(check(field, mx, my)) {
printf("YES\n");
return 0;
}
}
}
printf("NO\n");
return 0;
}