結果

問題 No.2641 draw X
ユーザー KudeKude
提出日時 2024-02-19 22:00:17
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 2,072 bytes
コンパイル時間 3,808 ms
コンパイル使用メモリ 282,708 KB
実行使用メモリ 19,220 KB
最終ジャッジ日時 2024-02-19 22:00:25
合計ジャッジ時間 7,416 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 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 1 ms
6,676 KB
testcase_09 AC 1 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 1 ms
6,676 KB
testcase_15 AC 162 ms
19,220 KB
testcase_16 AC 171 ms
19,220 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 1 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 11 ms
6,676 KB
testcase_21 AC 20 ms
6,676 KB
testcase_22 AC 9 ms
6,676 KB
testcase_23 AC 16 ms
6,676 KB
testcase_24 AC 6 ms
6,676 KB
testcase_25 AC 6 ms
6,676 KB
testcase_26 AC 23 ms
6,676 KB
testcase_27 AC 6 ms
6,676 KB
testcase_28 AC 46 ms
11,272 KB
testcase_29 AC 106 ms
18,332 KB
testcase_30 AC 92 ms
15,392 KB
testcase_31 AC 73 ms
11,824 KB
testcase_32 AC 124 ms
18,024 KB
testcase_33 AC 125 ms
18,228 KB
testcase_34 AC 81 ms
13,928 KB
testcase_35 AC 69 ms
11,432 KB
testcase_36 AC 118 ms
17,776 KB
testcase_37 AC 134 ms
18,536 KB
testcase_38 AC 125 ms
16,780 KB
testcase_39 AC 144 ms
18,996 KB
testcase_40 AC 131 ms
18,232 KB
testcase_41 AC 103 ms
16,876 KB
testcase_42 AC 130 ms
17,536 KB
testcase_43 AC 128 ms
17,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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");
}
0