結果

問題 No.2641 draw X
ユーザー ponjuiceponjuice
提出日時 2024-02-11 17:39:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 2,021 bytes
コンパイル時間 2,346 ms
コンパイル使用メモリ 210,744 KB
実行使用メモリ 28,416 KB
最終ジャッジ日時 2024-02-13 14:53:50
合計ジャッジ時間 5,484 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 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 1 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 2 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 2 ms
6,548 KB
testcase_15 AC 78 ms
28,416 KB
testcase_16 AC 90 ms
28,416 KB
testcase_17 AC 2 ms
6,548 KB
testcase_18 AC 2 ms
6,548 KB
testcase_19 AC 2 ms
6,548 KB
testcase_20 AC 9 ms
6,548 KB
testcase_21 AC 17 ms
7,424 KB
testcase_22 AC 7 ms
6,548 KB
testcase_23 AC 14 ms
6,912 KB
testcase_24 AC 6 ms
6,548 KB
testcase_25 AC 5 ms
6,548 KB
testcase_26 AC 18 ms
7,680 KB
testcase_27 AC 5 ms
6,548 KB
testcase_28 AC 33 ms
13,056 KB
testcase_29 AC 63 ms
23,168 KB
testcase_30 AC 63 ms
19,840 KB
testcase_31 AC 45 ms
14,464 KB
testcase_32 AC 73 ms
23,296 KB
testcase_33 AC 72 ms
23,168 KB
testcase_34 AC 42 ms
15,744 KB
testcase_35 AC 38 ms
13,440 KB
testcase_36 AC 89 ms
25,728 KB
testcase_37 AC 92 ms
27,136 KB
testcase_38 AC 90 ms
24,576 KB
testcase_39 AC 103 ms
28,032 KB
testcase_40 AC 91 ms
26,752 KB
testcase_41 AC 80 ms
24,576 KB
testcase_42 AC 93 ms
25,600 KB
testcase_43 AC 91 ms
24,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<string>s(h+2, string(w+2, '.'));
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> s[i][j];
        }
    }

    vector<vector<int>> mx1(h + 2, vector<int>(w + 2, 0));
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(s[i][j] == '#') mx1[i][j] = mx1[i - 1][j - 1] + 1;
        }
    }
    vector<vector<int>> mx2(h + 2, vector<int>(w + 2, 0));
    for(int i = 1; i <= h; i++){
        for(int j = w; j >= 1; j--){
            if(s[i][j] == '#') mx2[i][j] = mx2[i - 1][j + 1] + 1;
        }
    }
    vector<vector<int>> mx3(h + 2, vector<int>(w + 2, 0));
    for(int i = h; i >= 1; i--){
        for(int j = 1; j <= w; j++){
            if(s[i][j] == '#') mx3[i][j] = mx3[i + 1][j - 1] + 1;
        }
    }
    vector<vector<int>> mx4(h + 2, vector<int>(w + 2, 0));
    for(int i = h; i >= 1; i--){
        for(int j = w; j >= 1; j--){
            if(s[i][j] == '#') mx4[i][j] = mx4[i + 1][j + 1] + 1;
        }
    }

    vector<vector<int>> imos1(h + 2, vector<int>(w + 2, 0));
    vector<vector<int>> imos2(h + 2, vector<int>(w + 2, 0));
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            int l = min({mx1[i][j], mx2[i][j], mx3[i][j], mx4[i][j]}) - 1;
            if(l <= 0) continue;
            imos1[i - l][j - l]++;
            imos1[i + l + 1][j + l + 1]--;
            imos2[i - l][j + l]++;
            imos2[i + l + 1][j - l - 1]--;
        }
    }

    for(int i = 1; i < h + 2; i++){
        for(int j = 1; j <= w; j++){
            imos1[i][j] += imos1[i - 1][j - 1];
            imos2[i][j] += imos2[i - 1][j + 1];
        }
    }

    bool same = true;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(s[i][j] == '#' && imos1[i][j] + imos2[i][j] == 0){
                same = false;
            }
        }
    }
    
    cout << (same ? "Yes" : "No") << endl;
}
0