結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
pyonth
|
| 提出日時 | 2021-02-02 21:17:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,523 bytes |
| コンパイル時間 | 1,919 ms |
| コンパイル使用メモリ | 197,856 KB |
| 最終ジャッジ日時 | 2025-01-18 10:55:09 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 WA * 1 |
| other | AC * 27 WA * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr int inf = 1e9 + 10;
constexpr ll INF = (ll)4e18 + 10;
constexpr int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
constexpr int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
template <class T>
inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T>
inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
int h, w;
cin >> h >> w;
string a[h];
rep(i, h) cin >> a[i];
int cnt = 0;
rep(i, h) rep(j, w) {
if (a[i][j] == '#') cnt++;
}
repl(i, -h, h) repl(j, -w, w) {
if (i == 0 and j == 0) continue;
int m = 0;
vector<vector<int>> c(h, vector<int>(w));
rep(s, h) rep(t, w) {
if (s + i < 0 or h <= s + i or t + j < 0 or w <= t + j or a[s][t] == '.' or c[s][t])
continue;
if (a[s][t] == a[s + i][t + j] and c[s][t] == 0 and c[s + i][t + i] == 0) {
c[s][t] = c[s + i][t + j] = 1;
m += 2;
}
}
if (m == cnt) {
cout << "YES" << endl;
return 0;
}
}
cout << "NO" << endl;
return 0;
}
pyonth