結果
問題 | No.179 塗り分け |
ユーザー |
|
提出日時 | 2021-01-09 07:52:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,039 bytes |
コンパイル時間 | 1,304 ms |
コンパイル使用メモリ | 136,792 KB |
最終ジャッジ日時 | 2025-01-17 15:08:54 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 38 WA * 2 |
ソースコード
#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); for(int i = 0; i < h; ++i) cin >> s[i]; 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; }