結果

問題 No.2641 draw X
ユーザー t98slidert98slider
提出日時 2024-03-10 20:37:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,633 bytes
コンパイル時間 2,978 ms
コンパイル使用メモリ 216,976 KB
実行使用メモリ 67,548 KB
最終ジャッジ日時 2024-03-10 20:37:59
合計ジャッジ時間 7,465 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 1 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 WA -
testcase_09 AC 2 ms
6,548 KB
testcase_10 WA -
testcase_11 AC 2 ms
6,548 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
6,548 KB
testcase_15 AC 93 ms
59,136 KB
testcase_16 AC 474 ms
67,548 KB
testcase_17 AC 2 ms
6,548 KB
testcase_18 AC 1 ms
6,548 KB
testcase_19 AC 2 ms
6,548 KB
testcase_20 AC 9 ms
7,168 KB
testcase_21 AC 19 ms
12,032 KB
testcase_22 AC 9 ms
6,912 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 6 ms
6,548 KB
testcase_26 WA -
testcase_27 AC 8 ms
6,548 KB
testcase_28 AC 37 ms
23,936 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 75 ms
28,032 KB
testcase_32 WA -
testcase_33 AC 217 ms
48,120 KB
testcase_34 AC 97 ms
29,696 KB
testcase_35 AC 78 ms
25,728 KB
testcase_36 WA -
testcase_37 AC 209 ms
56,320 KB
testcase_38 AC 102 ms
50,432 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 106 ms
52,992 KB
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

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

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<int> Sp, Sm;
    auto rec = [&](auto rec, int y, int x, int ds) -> int {
        if(y < 0 || x < 0 || y >= h || x >= w) return 1;
        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] = 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;
            bool flg = true;
            for(int s = 0; s < 4; s++){
                if(rec(rec, y, x, s) == 0){
                    flg = false;
                    break;
                }
            }
            if(flg){
                Sp.push_back(y + x);
                Sm.push_back(y - x);
            }
        }
    }
    sort(Sp.begin(), Sp.end());
    Sp.erase(unique(Sp.begin(), Sp.end()), Sp.end());
    sort(Sm.begin(), Sm.end());
    Sm.erase(unique(Sm.begin(), Sm.end()), Sm.end());
    for(int y = 0; y < h; y++){
        for(int x = 0; x < w; x++){
            if(A[y][x] == '.') continue;
            if(binary_search(Sp.begin(), Sp.end(), y + x) || binary_search(Sm.begin(), Sm.end(), y - x))continue;
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}
0