結果
| 問題 | No.179 塗り分け |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-28 18:35:46 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 236 ms / 3,000 ms |
| コード長 | 2,337 bytes |
| 記録 | |
| コンパイル時間 | 4,364 ms |
| コンパイル使用メモリ | 380,240 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2026-03-28 18:36:01 |
| 合計ジャッジ時間 | 10,899 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = unsigned __int128_t;
using mint = atcoder::static_modint<998244353>;
const int mod = 998244353;
#include <chrono>
mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1};
int dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
template<class T>
bool chmin(T& a, const T& b){
if (b < a){
a = b;
return true;
}
else {
return false;
}
}
template<class T>
bool chmax(T& a, const T& b){
if (a < b){
a = b;
return true;
}
else {
return false;
}
}
void solve(){
int h, w;
cin >> h >> w;
int cnt = 0;
vector<string> s(h);
for (int i = 0; i < h; i++){
cin >> s[i];
for (int j = 0; j < w; j++){
if (s[i][j] == '#'){
cnt++;
}
}
}
if (cnt == 0){
cout << "NO" << '\n';
return;
}
for (int i = -h; i <= h; i++){
for (int j = -w; j <= w; j++){
if (i == 0 && j == 0){
continue;
}
vector<vector<bool>> used(h, vector<bool> (w, false));
bool ok = true;
for (int a = 0; a < h; a++){
for (int b = 0; b < w; b++){
if (s[a][b] == '#' && !used[a][b]){
int x = a + i, y = b + j;
if (x < 0 || x >= h || y < 0 || y >= w){
ok = false;
}
else {
if (s[x][y] == '#'){
used[x][y] = true;
}
else {
ok = false;
}
}
}
}
}
if (ok){
cout << "YES" << '\n';
return;
}
}
}
cout << "NO" << '\n';
};
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
while(t--){
cout << fixed << setprecision(15);
solve();
}
}