結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
oxyshower
|
| 提出日時 | 2020-01-09 12:50:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 156 ms / 3,000 ms |
| コード長 | 1,514 bytes |
| コンパイル時間 | 1,767 ms |
| コンパイル使用メモリ | 176,220 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-23 15:04:39 |
| 合計ジャッジ時間 | 5,196 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
#include "LOCAL_DEBUG.hpp"
#endif
#define int long long
template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
for (auto &e : t) fill(e, v);
}
// auto v = make_vec<int>(h, w);
// fill(v, 0);
signed main(){
int h, w; cin >> h >> w;
vector<string> s(h);
for(int i = 0; i < h; i++){
cin >> s[i];
}
for(int i = -h; i < h; i++){
for(int j = -w; j < w; j++){
if(i == 0 && j == 0) continue;
auto visited = make_vec<int>(h, w);
fill(visited, 0);
bool judge = true, cnt = 0;
for(int k = 0; k < h; k++){
for(int l = 0; l < w; l++){
if(visited[k][l]) continue;
if(s[k][l] == '#'){
if(visited[k][l]) continue;
if((k + i < 0 || h <= k + i || l + j < 0 || w <= l + j) || s[k + i][l + j] == '.'){
judge = false;
}else{
visited[k + i][l + j] = 1;
cnt = 1;
}
}
}
}
if(judge && cnt){
cout << "YES" << endl;
return 0;
}
}
}
cout << "NO" << endl;
return 0;
}
oxyshower