結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-09 13:31:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 296 ms / 3,000 ms |
| コード長 | 2,193 bytes |
| コンパイル時間 | 1,520 ms |
| コンパイル使用メモリ | 136,672 KB |
| 最終ジャッジ日時 | 2025-01-17 15:36:26 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;
template<class T>
inline bool chmax(T& x, T y){
if(x < y){
x = y;
return true;
}
return false;
}
template<class T>
inline bool chmin(T& x, T y){
if(x > y){
x = y;
return true;
}
return false;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int h, w;
cin >> h >> w;
vector<string> s(h);
int black = 0;
for(int i = 0; i < h; ++i){
cin >> s[i];
black += count(begin(s[i]), end(s[i]), '#');
}
if(black == 0){
cout << "NO\n";
return 0;
}
for(int dx = -h; dx <= h; ++dx){
for(int dy = -w; dy <= w; ++dy){
if(dx == 0 && dy == 0) continue;
vector<vector<bool>> used(h, vector<bool>(w));
for(int x = 0; x < h; ++x){
for(int y = 0; y < w; ++y){
if(used[x][y] || s[x][y] == '.') continue;
int nx = x + dx, ny = y + dy;
if(nx < 0 || nx >= h || ny < 0 || ny >= w || used[nx][ny] || s[nx][ny] == '.') continue;
used[x][y] = used[nx][ny] = true;
}
}
bool ok = true;
for(int x = 0; x < h; ++x){
for(int y = 0; y < w; ++y){
if(s[x][y] == '#' && !used[x][y]) ok = false;
}
}
if(ok){
cout << "YES\n";
return 0;
}
}
}
cout << "NO\n";
return 0;
}