結果

問題 No.2641 draw X
ユーザー kokoseikokosei
提出日時 2024-02-19 23:11:51
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,077 bytes
コンパイル時間 3,602 ms
コンパイル使用メモリ 271,124 KB
実行使用メモリ 129,368 KB
最終ジャッジ日時 2024-02-19 23:12:14
合計ジャッジ時間 16,113 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
6,676 KB
testcase_04 AC 2 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 2 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 88 ms
59,520 KB
testcase_16 AC 1,610 ms
125,404 KB
testcase_17 AC 1 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 1 ms
6,676 KB
testcase_20 AC 68 ms
9,164 KB
testcase_21 AC 82 ms
14,076 KB
testcase_22 AC 91 ms
11,364 KB
testcase_23 AC 60 ms
11,748 KB
testcase_24 AC 5 ms
6,676 KB
testcase_25 AC 9 ms
6,676 KB
testcase_26 AC 161 ms
17,016 KB
testcase_27 AC 51 ms
7,580 KB
testcase_28 AC 60 ms
24,448 KB
testcase_29 AC 78 ms
47,436 KB
testcase_30 AC 120 ms
40,732 KB
testcase_31 AC 165 ms
32,080 KB
testcase_32 AC 191 ms
50,008 KB
testcase_33 AC 1,283 ms
113,308 KB
testcase_34 AC 565 ms
62,712 KB
testcase_35 AC 603 ms
59,716 KB
testcase_36 AC 489 ms
62,204 KB
testcase_37 TLE -
testcase_38 AC 877 ms
67,664 KB
testcase_39 AC 857 ms
75,400 KB
testcase_40 TLE -
testcase_41 AC 345 ms
55,484 KB
testcase_42 AC 1,230 ms
86,216 KB
testcase_43 AC 1,077 ms
84,752 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<vector<int>>>(H, vector<vector<int>>(W, vector<int>(4, -1)));
    for(int i = 0;i < H;i++)cin >> S[i];
    using pp = pair<int, tuple<int, int, int>>;
    priority_queue<pp> que;
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            if(S[i][j] == '.')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))continue;
                    if(S[x][y] == '#')c++;
                }
                if(c == 4)l = m;
                else r = m;
            }
            if(l > 0){
                for(int d = 0;d < 4;d++){
                    power[i][j][d] = l;
                    que.push({l, {i, j, d}});
                }
            }
        }
    }
    while(que.size()){
        auto [p, v] = que.top(); que.pop();
        auto [x, y, d] = v;
        if(p < power[x][y][d])continue;
        int nx = x + dx[d], ny = y + dy[d];
        if(!inside(nx, ny))continue;
        if(S[nx][ny] == '.')continue;
        if(power[nx][ny][d] < p - 1){
            power[nx][ny][d] = p - 1;
            if(p - 1 > 0)que.push({p - 1, {nx, ny, d}});
        }
    }
    bool f = true;
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            if(S[i][j] != '#')continue;
            bool g = false;
            for(int d = 0;d < 4;d++){
                if(power[i][j][d] != -1)g = true;
            }
            f &= g;
        }
    }
    cout << (f ? "Yes\n" : "No\n");
    return 0;
}
0