結果

問題 No.2641 draw X
ユーザー kokoseikokosei
提出日時 2024-02-19 22:33:55
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,222 bytes
コンパイル時間 3,063 ms
コンパイル使用メモリ 264,812 KB
実行使用メモリ 21,428 KB
最終ジャッジ日時 2024-02-19 22:34:05
合計ジャッジ時間 8,711 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 1 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 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 16 ms
8,704 KB
testcase_16 AC 411 ms
21,428 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 WA -
testcase_21 AC 26 ms
6,676 KB
testcase_22 WA -
testcase_23 AC 15 ms
6,676 KB
testcase_24 AC 3 ms
6,676 KB
testcase_25 AC 4 ms
6,676 KB
testcase_26 AC 48 ms
6,676 KB
testcase_27 WA -
testcase_28 AC 20 ms
6,676 KB
testcase_29 AC 17 ms
7,552 KB
testcase_30 AC 36 ms
7,168 KB
testcase_31 AC 61 ms
6,676 KB
testcase_32 AC 68 ms
8,064 KB
testcase_33 AC 396 ms
20,340 KB
testcase_34 AC 164 ms
13,472 KB
testcase_35 AC 176 ms
13,172 KB
testcase_36 AC 115 ms
8,800 KB
testcase_37 WA -
testcase_38 AC 192 ms
9,372 KB
testcase_39 AC 186 ms
10,092 KB
testcase_40 AC 714 ms
21,088 KB
testcase_41 AC 93 ms
8,192 KB
testcase_42 WA -
testcase_43 AC 230 ms
11,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int H, W;
vector<string> S;
bool inside(int x, int y){
    return 0 <= x && x < H && 0 <= y && y < W;
}
int dx[4] = {1, 1, -1, -1};
int dy[4] = {1, -1, -1, 1};
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> H >> W;
    S.resize(H);
    auto vtd = vector<vector<bool>>(H, vector<bool>(W));
    auto power = vector<vector<int>>(H, vector<int>(W, -1));
    for(int i = 0;i < H;i++)cin >> S[i];
    using pp = pair<int, pair<int, int>>;
    priority_queue<pp> que;
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            int cnt = 0;
            for(int d = 0;d < 4;d++){
                int x = i + dx[d], y = j + dy[d];
                if(!inside(x, y))continue;
                if(S[x][y] == '#')cnt++;
            }
            if(cnt != 4)continue;
            int l = 0, r = max(H, W) + 1;
            while(r - l > 1){
                int m = (l + r) / 2;
                int c = 0;
                for(int d = 0;d < 4;d++){
                    int x = i + dx[d] * m, y = j + dy[d] * m;
                    if(!inside(x, y)){
                        c = -100; continue;
                    }
                    if(S[x][y] == '#')c++;
                }
                if(c == 4)l = m;
                else r = m;
            }
            if(l > 0){
                power[i][j] = l;
                if(l > 0)que.push({l, {i, j}});
            }
        }
    }
    while(que.size()){
        auto [p, v] = que.top(); que.pop();
        auto [x, y] = v;
        if(p < power[x][y])continue;
        for(int d = 0;d < 4;d++){
            int nx = x + dx[d], ny = y + dy[d];
            if(!inside(nx, ny))continue;
            if(S[nx][ny] == '.')continue;
            if(power[nx][ny] < p - 1){
                power[nx][ny] = p - 1;
                if(p - 1 > 0)que.push({p - 1, {nx, ny}});
            }
        }
    }
    bool f = true;
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            if(S[i][j] == '#' && power[i][j] == -1)f = false;
            //cout << power[i][j] << " \n"[j + 1 == W];
        }
    }
    cout << (f ? "Yes\n" : "No\n");
    return 0;
}
0