結果

問題 No.2641 draw X
ユーザー 👑 emthrm
提出日時 2024-02-19 22:28:43
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 3,065 bytes
コンパイル時間 3,434 ms
コンパイル使用メモリ 256,424 KB
実行使用メモリ 24,064 KB
最終ジャッジ日時 2024-09-29 02:21:49
合計ジャッジ時間 5,425 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 998244353;
// constexpr int MOD = 1000000007;
constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1};
constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1};
constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U>
inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U>
inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
IOSetup() {
std::cin.tie(nullptr);
std::ios_base::sync_with_stdio(false);
std::cout << fixed << setprecision(20);
}
} iosetup;
int main() {
int h, w; cin >> h >> w;
vector<string> s(h);
for (string& s_i : s) cin >> s_i;
vector d1(h, vector(w, 0));
REP(diag, h + w - 1) {
for (auto [y, x] = (diag < w ? make_pair(0, diag) : make_pair(diag - (w - 1), w - 1)); y < h && x >= 0;) {
if (s[y][x] == '.') {
++y;
--x;
} else {
int k = 1;
while (y + k < h && x - k >= 0 && s[y + k][x - k] == '#') ++k;
REP(i, k) d1[y + i][x - i] = min(i + 1, k - i);
y += k;
x -= k;
}
}
}
vector d2(h, vector(w, 0));
REP(diag, h + w - 1) {
for (auto [y, x] = (diag < h ? make_pair(diag, 0) : make_pair(0, diag - (h - 1))); y < h && x < w;) {
if (s[y][x] == '.') {
++y;
++x;
} else {
int k = 1;
while (y + k < h && x + k < w && s[y + k][x + k] == '#') ++k;
REP(i, k) d2[y + i][x + i] = min(i + 1, k - i);
y += k;
x += k;
}
}
}
// REP(i, h) REP(j, w) cout << d1[i][j] << " \n"[j + 1 == w];
// cout << '\n';
// REP(i, h) REP(j, w) cout << d2[i][j] << " \n"[j + 1 == w];
vector nd1(h, vector(w, 0)), nd2(h, vector(w, 0));
REP(i, h) REP(j, w) {
const int l = min(d1[i][j], d2[i][j]);
if (l >= 2) {
nd1[i - l + 1][j + l - 1] = max(nd1[i - l + 1][j + l - 1], l * 2 - 1);
nd2[i - l + 1][j - l + 1] = max(nd2[i - l + 1][j - l + 1], l * 2 - 1);
}
}
// REP(i, h) REP(j, w) cout << nd1[i][j] << " \n"[j + 1 == w];
// cout << '\n';
// REP(i, h) REP(j, w) cout << nd2[i][j] << " \n"[j + 1 == w];
vector is_painted(h, vector(w, 0));
REP(diag, h + w - 1) {
int l = 0;
for (auto [y, x] = (diag < w ? make_pair(0, diag) : make_pair(diag - (w - 1), w - 1)); y < h && x >= 0; ++y, --x) {
l = max(l - 1, nd1[y][x]);
if (l > 0) is_painted[y][x] = true;
}
}
REP(diag, h + w - 1) {
int l = 0;
for (auto [y, x] = (diag < h ? make_pair(diag, 0) : make_pair(0, diag - (h - 1))); y < h && x < w; ++y, ++x) {
l = max(l - 1, nd2[y][x]);
if (l > 0) is_painted[y][x] = true;
}
}
REP(i, h) REP(j, w) {
if (s[i][j] == '#' && !is_painted[i][j]) {
cout << "No\n";
return 0;
}
}
cout << "Yes\n";
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0