結果

問題 No.2641 draw X
ユーザー kokoseikokosei
提出日時 2024-02-19 23:19:48
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,134 bytes
コンパイル時間 5,505 ms
コンパイル使用メモリ 261,200 KB
実行使用メモリ 59,392 KB
最終ジャッジ日時 2024-02-19 23:20:17
合計ジャッジ時間 8,186 ms
ジャッジサーバーID
(参考情報)
judge14 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 WA -
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 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
6,676 KB
testcase_19 AC 1 ms
6,676 KB
testcase_20 AC 16 ms
7,168 KB
testcase_21 AC 23 ms
12,032 KB
testcase_22 AC 21 ms
6,912 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 6 ms
6,676 KB
testcase_26 WA -
testcase_27 AC 11 ms
6,676 KB
testcase_28 AC 46 ms
24,832 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 69 ms
28,188 KB
testcase_32 WA -
testcase_33 AC 273 ms
47,856 KB
testcase_34 AC 124 ms
30,848 KB
testcase_35 AC 135 ms
25,968 KB
testcase_36 WA -
testcase_37 AC 555 ms
56,576 KB
testcase_38 AC 179 ms
50,688 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 234 ms
52,992 KB
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

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 power = vector<vector<vector<int>>>(H + 1, vector<vector<int>>(W + 1, vector<int>(2, 0)));
    for(int i = 0;i < H;i++)cin >> S[i];
    using pp = pair<int, tuple<int, int, int>>;
    queue<pp> que;
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            if(S[i][j] == '.')continue;
            {
                int c = 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] == '#')c++;
                }
                if(c != 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))continue;
                    if(S[x][y] == '#')c++;
                }
                if(c == 4)l = m;
                else r = m;
            }
            power[i - l][j - l][0]++;
            power[i + l + 1][j + l + 1][0]--;
            power[i - l][j + l][1]++;
            power[i + l + 1][j - l + 1][1]--;
        }
    }
    for(int x = 0;x < H;x++){
        for(int y = 0;y < W;y++){
            for(int m = 0;m < 2;m++){
                int nx = x + dx[m], ny = y + dy[m];
                if(!inside(nx, ny))continue;
                power[nx][ny][m] += power[x][y][m];
            }
        }
    }
    bool f = true;
    for(int x = 0;x < H;x++){
        for(int y = 0;y < W;y++){
            bool g = false;
            for(int m = 0;m < 2;m++){
                if(power[x][y][m] > 0)g = true;
            }
            f &= g;
        }
    }
    cout << (f ? "Yes\n" : "No\n");
    return 0;
}
0