結果

問題 No.2646 Cycle Maze
ユーザー shinnshinnshinnshinn
提出日時 2024-02-12 17:01:29
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,724 bytes
コンパイル時間 3,129 ms
コンパイル使用メモリ 259,672 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-25 17:30:36
合計ジャッジ時間 5,398 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 1 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 WA -
testcase_16 AC 1 ms
6,676 KB
testcase_17 WA -
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 1 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 1 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 5 ms
6,676 KB
testcase_26 AC 9 ms
6,676 KB
testcase_27 AC 22 ms
6,676 KB
testcase_28 AC 4 ms
6,676 KB
testcase_29 AC 5 ms
6,676 KB
testcase_30 AC 5 ms
6,676 KB
testcase_31 AC 2 ms
6,676 KB
testcase_32 AC 2 ms
6,676 KB
testcase_33 AC 9 ms
6,676 KB
testcase_34 AC 17 ms
6,676 KB
testcase_35 WA -
testcase_36 AC 9 ms
6,676 KB
testcase_37 AC 10 ms
6,676 KB
testcase_38 AC 2 ms
6,676 KB
testcase_39 AC 7 ms
6,676 KB
testcase_40 AC 2 ms
6,676 KB
testcase_41 AC 9 ms
6,676 KB
testcase_42 AC 5 ms
6,676 KB
testcase_43 AC 3 ms
6,676 KB
testcase_44 AC 6 ms
6,676 KB
testcase_45 AC 45 ms
6,676 KB
testcase_46 AC 49 ms
6,676 KB
testcase_47 AC 9 ms
6,676 KB
testcase_48 AC 37 ms
6,676 KB
testcase_49 AC 43 ms
6,676 KB
testcase_50 AC 91 ms
6,676 KB
testcase_51 AC 150 ms
6,676 KB
testcase_52 AC 153 ms
6,676 KB
testcase_53 AC 152 ms
6,676 KB
testcase_54 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

inline bool in_grid(int i, int j, int h, int w) {
    return 0 <= i && i < h && 0 <= j && j < w;
}

const int di[] = {1, -1, 0, 0};
const int dj[] = {0, 0, 1, -1};

void solve(){
    int h, w, t;
    cin >> h >> w >> t;
    pair<int,int> ss, g;
    cin >> ss.first >> ss.second >> g.first >> g.second;
    --ss.first; ss.second--; g.first--; g.second--;
    vector<vector<char>> s(h, vector<char>(w));
    for(int i = 0;i < h; ++i){
        for(int j = 0;j < w; ++j){
            cin >> s[i][j];
            s[i][j] -= '0';
        }
    }
    vector init = s;
    vector ok(h, vector<bool>(w));
    ok[ss.first][ss.second] = true;
    for(int ii = 1;ii < t; ++ii){
        for(int i = 0;i < h; ++i){
            for(int j = 0;j < w; ++j){
                if(s[i][j] == 0){
                    s[i][j] = init[i][j];
                } else {
                    --s[i][j];
                }
            }
        }

        vector nok(h, vector<bool>(w));
        for(int i = 0;i < h; ++i){
            for(int j = 0;j < w; ++j){
                if(!ok[i][j])continue;
                for(int d = 0;d < 4; ++d){
                    int ni = i + di[d];
                    int nj = j + dj[d];
                    if(!in_grid(ni, nj, h, w))continue;
                    if(s[ni][nj] == 0)continue;
                    nok[ni][nj] = true;
                }
            }
        }

        ok = move(nok);

        if(ok[g.first][g.second]){
            cout << "Yes" << endl;
            return;
        }
    }

    cout << "No" << endl;
}


int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout<<fixed<<setprecision(12);
    solve();
    return 0;
}
0