結果
| 問題 |
No.2641 draw X
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2024-02-19 22:00:17 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 157 ms / 2,000 ms |
| コード長 | 2,072 bytes |
| コンパイル時間 | 3,365 ms |
| コンパイル使用メモリ | 283,296 KB |
| 実行使用メモリ | 19,224 KB |
| 最終ジャッジ日時 | 2024-09-29 01:58:52 |
| 合計ジャッジ時間 | 6,882 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int h, w;
cin >> h >> w;
vector<string> s(h);
rep(i, h) cin >> s[i];
constexpr int INF = 1001001001;
VVI a(h, VI(w, INF));
rep(_, 4) {
VVI dp(h, VI(w));
rep(i, h - 1) rep(j, w - 1) {
if (s[i][j] == '#') {
chmax(dp[i][j], 1);
if (s[i+1][j+1] == '#') dp[i+1][j+1] = dp[i][j] + 1;
if (dp[i][j] == 1) dp[i][j] = 0;
}
}
rep(i, h) rep(j, w) chmin(a[i][j], dp[i][j]);
VVI na(w, VI(h));
vector<string> ns(w, string(h, '.'));
rep(i, h) rep(j, w) {
int ni = j, nj = h - 1 - i;
na[ni][nj] = a[i][j];
ns[ni][nj] = s[i][j];
}
swap(h, w);
swap(a, na);
swap(s, ns);
}
vector<string> t(h, string(w, '.'));
rep(_, 4) {
VVI dp(h, VI(w));
rep(i, h) rep(j, w) {
chmax(dp[i][j], a[i][j]);
if (dp[i][j]) {
t[i][j] = '#';
if (i + 1 < h && j + 1 < w) chmax(dp[i+1][j+1], dp[i][j] - 1);
}
}
VVI na(w, VI(h));
vector<string> ns(w, string(h, '.')), nt(w, string(h, '.'));
rep(i, h) rep(j, w) {
int ni = j, nj = h - 1 - i;
na[ni][nj] = a[i][j];
ns[ni][nj] = s[i][j];
nt[ni][nj] = t[i][j];
}
swap(h, w);
swap(a, na);
swap(s, ns);
swap(t, nt);
}
cout << (s == t ? "Yes\n" : "No\n");
}
Kude