結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-08-15 18:25:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 3,000 ms |
| コード長 | 1,382 bytes |
| コンパイル時間 | 700 ms |
| コンパイル使用メモリ | 65,452 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-23 14:51:51 |
| 合計ジャッジ時間 | 1,814 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
#include<iostream>
using namespace std;
#define inRange(x, a, b) a <= x && x < b
int main(){
int h, w;
cin >> h >> w;
char mat[50][50];
bool judge = true;
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
cin >> mat[i][j];
if(mat[i][j] == '#') judge = false;
}
}
if(judge){
cout << "NO" << endl;
return 0;
}
for(int di = 0; !judge && di < h; di++){
for(int dj = -w+1; !judge && dj < w; dj++){
if(di == 0 && dj == 0) continue;
int check[51][51] = {};
bool inner = true;
for(int i = 0; inner && i < h; i++){
for(int j = 0; inner && j < w; j++){
if(mat[i][j] == '#' && check[i][j] == 0){
int ni = i + di;
int nj = j + dj;
if(inRange(ni, 0, h) && inRange(nj, 0, w) && mat[ni][nj] == '#' && check[ni][nj] == 0){
check[i][j] = 1;
check[ni][nj] = 2;
}else{
inner = false;
}
}
}
}
if(inner) judge = true;
}
}
if(judge) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
}