結果

問題 No.2646 Cycle Maze
ユーザー t98slidert98slider
提出日時 2024-02-25 19:47:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 416 ms / 2,500 ms
コード長 1,352 bytes
コンパイル時間 2,420 ms
コンパイル使用メモリ 220,624 KB
実行使用メモリ 14,464 KB
最終ジャッジ日時 2024-02-25 19:47:10
合計ジャッジ時間 6,525 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 2 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 1 ms
6,548 KB
testcase_15 AC 2 ms
6,548 KB
testcase_16 AC 1 ms
6,548 KB
testcase_17 AC 1 ms
6,548 KB
testcase_18 AC 2 ms
6,548 KB
testcase_19 AC 2 ms
6,548 KB
testcase_20 AC 2 ms
6,548 KB
testcase_21 AC 2 ms
6,548 KB
testcase_22 AC 2 ms
6,548 KB
testcase_23 AC 2 ms
6,548 KB
testcase_24 AC 2 ms
6,548 KB
testcase_25 AC 11 ms
6,548 KB
testcase_26 AC 20 ms
6,548 KB
testcase_27 AC 46 ms
6,548 KB
testcase_28 AC 6 ms
6,548 KB
testcase_29 AC 17 ms
7,808 KB
testcase_30 AC 15 ms
6,548 KB
testcase_31 AC 5 ms
6,548 KB
testcase_32 AC 2 ms
6,548 KB
testcase_33 AC 12 ms
6,548 KB
testcase_34 AC 30 ms
6,548 KB
testcase_35 AC 27 ms
6,548 KB
testcase_36 AC 14 ms
6,548 KB
testcase_37 AC 13 ms
6,548 KB
testcase_38 AC 4 ms
6,548 KB
testcase_39 AC 19 ms
6,548 KB
testcase_40 AC 10 ms
6,548 KB
testcase_41 AC 20 ms
6,548 KB
testcase_42 AC 11 ms
6,548 KB
testcase_43 AC 4 ms
6,548 KB
testcase_44 AC 15 ms
7,424 KB
testcase_45 AC 101 ms
7,296 KB
testcase_46 AC 106 ms
8,320 KB
testcase_47 AC 20 ms
13,056 KB
testcase_48 AC 68 ms
7,424 KB
testcase_49 AC 96 ms
13,568 KB
testcase_50 AC 205 ms
8,960 KB
testcase_51 AC 402 ms
11,520 KB
testcase_52 AC 411 ms
12,032 KB
testcase_53 AC 416 ms
14,464 KB
testcase_54 AC 414 ms
14,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<class T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W, T, sy, sx, gy, gx, prv = -1;
    cin >> H >> W >> T >> sy >> sx >> gy >> gx;
    sy--, sx--, gy--, gx--;
    vector<string> A(H), B;
    cin >> A;
    B = A;
    vector dp(T, vector(H, vector<bool>(W)));
    queue<tuple<int,int,int>> que;
    dp[0][sy][sx] = true;
    que.emplace(0, sy, sx);
    while(!que.empty()){
        auto [t, y, x] = que.front();
        que.pop();
        if(t > prv){
            prv = t;
            for(int y = 0; y < H; y++){
                for(int x = 0; x < W; x++){
                    if(B[y][x] == '0') B[y][x] = A[y][x];
                    else B[y][x]--;
                }
            }
        }
        if(y == gy && x == gx){
            cout << "Yes\n";
            return 0;
        }
        if(t + 1 >= T) continue;
        for(int i = 0; i < 5; i++){
            int ny = y + (i == 0) - (i == 1);
            int nx = x + (i == 2) - (i == 3);
            if(ny < 0 || nx < 0 || ny >= H || nx >= W || B[ny][nx] == '0' || dp[t + 1][ny][nx]) continue;
            dp[t + 1][ny][nx] = true;
            que.emplace(t + 1, ny, nx);
        }
    }
    cout << "No\n";
}
0