結果

問題 No.2641 draw X
ユーザー t98slidert98slider
提出日時 2024-03-10 20:49:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,054 bytes
コンパイル時間 7,694 ms
コンパイル使用メモリ 213,056 KB
実行使用メモリ 67,072 KB
最終ジャッジ日時 2024-03-10 20:49:26
合計ジャッジ時間 8,334 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 1 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 103 ms
67,072 KB
testcase_16 AC 378 ms
67,072 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 16 ms
7,680 KB
testcase_21 AC 32 ms
13,184 KB
testcase_22 WA -
testcase_23 AC 26 ms
11,648 KB
testcase_24 AC 7 ms
6,912 KB
testcase_25 AC 7 ms
6,676 KB
testcase_26 AC 43 ms
13,568 KB
testcase_27 AC 10 ms
6,676 KB
testcase_28 AC 52 ms
25,572 KB
testcase_29 AC 104 ms
53,388 KB
testcase_30 AC 103 ms
45,104 KB
testcase_31 AC 93 ms
31,020 KB
testcase_32 AC 140 ms
53,560 KB
testcase_33 AC 279 ms
52,984 KB
testcase_34 AC 105 ms
31,852 KB
testcase_35 AC 154 ms
28,368 KB
testcase_36 AC 195 ms
60,288 KB
testcase_37 AC 471 ms
63,872 KB
testcase_38 AC 220 ms
57,216 KB
testcase_39 AC 241 ms
66,176 KB
testcase_40 AC 491 ms
62,848 KB
testcase_41 AC 158 ms
57,344 KB
testcase_42 WA -
testcase_43 AC 249 ms
58,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template<class T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}

template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
    if(vec.empty()) return os;
    os << vec[0];
    for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
    return os;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    vector<string> A(h);
    cin >> A;
    vector dp(h, vector(w, vector<int>(4, -1)));
    vector dp2(h, vector<int>(w)), dp3(h, vector<int>(w));
    auto rec = [&](auto rec, int y, int x, int ds) -> int {
        if(y < 0 || x < 0 || y >= h || x >= w) return 0;
        if(dp[y][x][ds] != -1) return dp[y][x][ds];
        if(A[y][x] == '.') return dp[y][x][ds] = 0;
        return dp[y][x][ds] = 1 + rec(rec, y + (ds & 1 ? 1 : -1), x + (ds & 2 ? 1 : -1), ds);
    };
    for(int y = 0; y < h; y++){
        for(int x = 0; x < w; x++){
            if(A[y][x] == '.') continue;
            int ans = 1 << 30;
            for(int s = 0; s < 4; s++){
                ans = min(ans, rec(rec, y, x, s));
            }
            if(ans >= 2) dp2[y][x] = dp3[y][x] = ans;
        }
    }
    for(int y = 0; y + 1 < h; y++){
        for(int x = 0; x < w; x++){
            if(x + 1 < w) dp2[y + 1][x + 1] = max(dp2[y + 1][x + 1], dp2[y][x] - 1);
            if(x >= 1) dp2[y + 1][x - 1] = max(dp2[y + 1][x - 1], dp2[y][x] - 1);
        }
    }
    for(int y = h - 1; y >= 1; y--){
        for(int x = 0; x < w; x++){
            if(x + 1 < w) dp3[y - 1][x + 1] = max(dp3[y - 1][x + 1], dp3[y][x] - 1);
            if(x >= 1) dp3[y - 1][x - 1] = max(dp3[y - 1][x - 1], dp3[y][x] - 1);
        }
    }

    for(int y = 0; y < h; y++){
        for(int x = 0; x < w; x++){
            if(A[y][x] == '.') continue;
            if(dp2[y][x] + dp3[y][x] == 0){
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
}
0