結果

問題 No.2641 draw X
ユーザー 👑 emthrmemthrm
提出日時 2024-02-19 22:28:43
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 3,065 bytes
コンパイル時間 2,887 ms
コンパイル使用メモリ 256,048 KB
実行使用メモリ 24,064 KB
最終ジャッジ日時 2024-02-19 22:28:48
合計ジャッジ時間 5,129 ms
ジャッジサーバーID
(参考情報)
judge16 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 36 ms
24,064 KB
testcase_16 AC 54 ms
24,064 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 4 ms
6,676 KB
testcase_21 AC 7 ms
6,676 KB
testcase_22 AC 4 ms
6,676 KB
testcase_23 AC 7 ms
6,676 KB
testcase_24 AC 3 ms
6,676 KB
testcase_25 AC 3 ms
6,676 KB
testcase_26 AC 8 ms
6,676 KB
testcase_27 AC 3 ms
6,676 KB
testcase_28 AC 13 ms
10,496 KB
testcase_29 AC 27 ms
19,584 KB
testcase_30 AC 25 ms
16,896 KB
testcase_31 AC 18 ms
12,288 KB
testcase_32 AC 34 ms
19,712 KB
testcase_33 AC 29 ms
19,456 KB
testcase_34 AC 18 ms
12,544 KB
testcase_35 AC 18 ms
11,392 KB
testcase_36 AC 38 ms
21,888 KB
testcase_37 AC 49 ms
22,912 KB
testcase_38 AC 31 ms
20,864 KB
testcase_39 AC 45 ms
23,680 KB
testcase_40 AC 59 ms
22,656 KB
testcase_41 AC 35 ms
20,864 KB
testcase_42 AC 36 ms
21,632 KB
testcase_43 AC 40 ms
21,120 KB
権限があれば一括ダウンロードができます

ソースコード

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;
}
0