結果

問題 No.2646 Cycle Maze
ユーザー GOTKAKO
提出日時 2024-02-27 07:56:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,240 bytes
コンパイル時間 2,266 ms
コンパイル使用メモリ 206,724 KB
最終ジャッジ日時 2025-02-19 21:41:09
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 47 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int H,W,T; cin >> H >> W >> T;
    int sx,sy,gx,gy; cin >> sx >> sy >> gx >> gy;
    sx--; sy--; gx--; gy--;

    vector<vector<bool>> ok(H,vector<bool>(W));
    vector<vector<int>> A(H,vector<int>(W));
    for(int i=0; i<H; i++) for(int k=0; k<W; k++){
        char c; cin >> c;
        A.at(i).at(k) = c-'0'+1;
    }
    ok.at(sx).at(sy) = true;

    bool yes = false;
    vector<int> dx = {-1,0,1,0},dy = {0,1,0,-1};
    for(int i=1; i<=T; i++){
        vector<vector<bool>> next(H,vector<bool>(W));
        for(int x=0; x<H; x++) for(int y=0; y<W; y++){
            if(!ok.at(x).at(y)) continue;
            for(int k=0; k<4; k++){
                int nx = x+dx.at(k),ny = y+dy.at(k);
                if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
                if(next.at(nx).at(ny)) continue;
                
                if((i+1)%A.at(nx).at(ny)) next.at(nx).at(ny) = true;
            }
            if((i+1)%A.at(x).at(y)) next.at(x).at(y) = true;
        }
        swap(ok,next);
        if(ok.at(gx).at(gy)) yes = true;
    }
    if(yes) cout << "Yes" << endl;
    else cout << "No" << endl;
}
0