結果
問題 |
No.179 塗り分け
|
ユーザー |
|
提出日時 | 2022-02-11 00:30:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 38 ms / 3,000 ms |
コード長 | 1,459 bytes |
コンパイル時間 | 2,338 ms |
コンパイル使用メモリ | 172,364 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 08:08:09 |
合計ジャッジ時間 | 3,570 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 40 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int H,W; cin >> H >> W; bool flag=false; vector<string> s; string a; for(int i = 0; i < H; i++){ cin >> a; s.push_back(a); if(s[i].find("#") != string::npos){ flag=true; } } if(!flag) { cout << "NO" << endl;; return 0; } for(int dy = -H; dy < H; dy++){ for(int dx = -W; dx < W; dx++) { if (dx == 0 && dy == 0){ continue; } auto ss = s; bool ng = false; int nx, ny; for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ if(ss[i][j]!='#'){ continue; } ny = i + dy; nx = j + dx; if(!(0 <= ny && ny < H)||!(0 <= nx && nx < W)) { ng=true; break; } if(ss[ny][nx]=='#'){ ss[ny][nx]='.'; }else{ ng=true; break; } } if(ng) break; } if(!ng){ cout << "YES" << endl; return 0; } } } cout << "NO" << endl; return 0; }