結果

問題 No.2641 draw X
ユーザー noya2noya2
提出日時 2024-02-13 21:01:11
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,379 bytes
コンパイル時間 3,074 ms
コンパイル使用メモリ 257,756 KB
実行使用メモリ 814,208 KB
最終ジャッジ日時 2024-02-13 21:01:19
合計ジャッジ時間 6,799 ms
ジャッジサーバーID
(参考情報)
judge11 / 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 1 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 1 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 1 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 114 ms
16,424 KB
testcase_16 AC 125 ms
16,424 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 1 ms
6,676 KB
testcase_20 RE -
testcase_21 AC 25 ms
6,676 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 WA -
testcase_27 RE -
testcase_28 MLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<typename T>
bool chmax(T &a, const T &b){
    if (a >= b){
        return false;
    }
    a = b;
    return true;
}
template<typename T>
bool chmin(T &a, const T &b){
    if (a <= b){
        return false;
    }
    a = b;
    return true;
}

vector<vector<int>> max_ur(vector<vector<char>> &a){
    int h = a.size();
    int w = a[0].size();
    vector<vector<int>> ans(h,vector<int>(w,0));
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){
        if (a[i][j] == '#'){
            ans[i][j] = 1;
            if (i > 0 && j > 0){
                chmax(ans[i][j],ans[i-1][j-1]+1);
            }
        }
    }
    return ans;
}

template<typename T>
void rotated(vector<vector<T>> &a){
    int h = a.size();
    int w = a[0].size();
    vector<vector<T>> b(w,vector<T>(w));
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){
        b[j][h-1-i] = a[i][j];
    }
    swap(a,b);
}

int main(){
    int h, w; cin >> h >> w;
    vector<vector<char>> a(h,vector<char>(w));
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){
        cin >> a[i][j];
    }
    vector<vector<int>> dp(h,vector<int>(w,h+w));
    for (int t = 0; t < 4; t++){
        auto ep = max_ur(a);
        for (int s = 0; s < 4-t; s++){
            rotated(ep);
        }
        for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){
            chmin(dp[i][j],ep[i][j]);
        }
        rotated(a);
    }
    vector<vector<int>> imosm(h,vector<int>(w,0)), imosp(h,vector<int>(w,0));
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){
        if (dp[i][j] <= 1) continue;
        int r = dp[i][j]-1;
        imosm[i-r][j-r]++;
        if (i+r+1 < h && j+r+1 < w){
            imosm[i+r+1][j+r+1]--;
        }
        imosp[i-r][j+r]++;
        if (i+r+1 < h && j-r-1 >= 0){
            imosp[i+r+1][j-r-1]--;
        }
    }
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){
        if (i+1 < h && j+1 < w){
            imosm[i+1][j+1] += imosm[i][j];
        }
        if (i+1 < h && j-1 >= 0){
            imosp[i+1][j-1] += imosp[i][j];
        }
    }
    bool ans = true;
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){
        if (a[i][j] == '#' && imosm[i][j]+imosp[i][j] == 0){
            ans = false;
            break;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}
0