結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
DeviceNeko
|
| 提出日時 | 2023-01-14 20:20:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 3,000 ms |
| コード長 | 1,454 bytes |
| コンパイル時間 | 2,041 ms |
| コンパイル使用メモリ | 171,980 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-26 05:54:01 |
| 合計ジャッジ時間 | 3,387 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
bool checkDyDx(int h, int w, int dy, int dx, vector<string> m) {
int i, j;
bool atLeastOnePaint=false;
for(i=0; i<h; i++) {
for(j=0; j<w; j++) {
if(m[i][j] == '#') {
if(i+dy >= 0 && j+dx >= 0
&& i+dy < h && j+dx < w
&& m[i+dy][j+dx] == '#') {
m[i][j] = '.';
m[i+dy][j+dx] = '.';
atLeastOnePaint = true;
}else {
//this dx, dy is not answer
return false;
}
}
}
}
if(atLeastOnePaint) {
return true;
}else {
return false;
}
}
int main() {
int h, w;
cin >> h >> w;
int i;
vector<string> vs;
string bufstr;
for(i=0; i<h; i++) {
cin >> bufstr;
vs.push_back(bufstr);
}
int j;
/*
for(i=0; i<h; i++) {
for(j=0; j<w; j++) {
cout << vs[i][j];
}
cout << endl;
}
*/
int dx, dy;
bool ans;
for(dy=0; dy<h; dy++) {
for(dx=0; dx<w; dx++) {
if(dy==0 && dx==0) {
continue;
}
if(checkDyDx(h, w, dy, dx, vs)
|| checkDyDx(h, w, dy, -dx, vs)) {
cout << "YES" << endl;
return 0;
}
}
}
cout << "NO" << endl;
return 0;
}
DeviceNeko