結果
| 問題 | 
                            No.2641 draw X
                             | 
                    
| コンテスト | |
| ユーザー | 
                             kokosei
                         | 
                    
| 提出日時 | 2024-02-19 22:33:55 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,222 bytes | 
| コンパイル時間 | 3,422 ms | 
| コンパイル使用メモリ | 264,136 KB | 
| 実行使用メモリ | 22,812 KB | 
| 最終ジャッジ日時 | 2024-09-29 02:25:31 | 
| 合計ジャッジ時間 | 7,899 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 34 WA * 7 | 
ソースコード
#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;
}
            
            
            
        
            
kokosei