結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 WA -
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 WA -
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 WA -
testcase_17 AC 2 ms
6,676 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 1 ms
6,676 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1 ms
6,676 KB
testcase_25 AC 11 ms
6,676 KB
testcase_26 AC 22 ms
6,676 KB
testcase_27 AC 51 ms
6,676 KB
testcase_28 AC 8 ms
6,676 KB
testcase_29 AC 17 ms
7,808 KB
testcase_30 AC 15 ms
6,676 KB
testcase_31 AC 5 ms
6,676 KB
testcase_32 AC 3 ms
6,676 KB
testcase_33 AC 13 ms
6,676 KB
testcase_34 AC 35 ms
6,676 KB
testcase_35 AC 29 ms
6,676 KB
testcase_36 AC 17 ms
6,676 KB
testcase_37 AC 13 ms
6,676 KB
testcase_38 AC 5 ms
6,676 KB
testcase_39 AC 18 ms
6,676 KB
testcase_40 AC 10 ms
6,676 KB
testcase_41 AC 21 ms
6,676 KB
testcase_42 AC 12 ms
6,676 KB
testcase_43 AC 4 ms
6,676 KB
testcase_44 AC 16 ms
7,424 KB
testcase_45 AC 112 ms
7,296 KB
testcase_46 AC 116 ms
8,320 KB
testcase_47 AC 21 ms
13,056 KB
testcase_48 AC 75 ms
7,424 KB
testcase_49 AC 102 ms
13,568 KB
testcase_50 AC 230 ms
8,960 KB
testcase_51 AC 451 ms
11,520 KB
testcase_52 AC 458 ms
12,032 KB
testcase_53 AC 457 ms
14,464 KB
testcase_54 AC 485 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 + 1, 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 == T) continue;
        if(!dp[t + 1][y][x]){
            que.emplace(t + 1, y, x);
            dp[t + 1][y][x] = true;
        }
        for(int i = 0; i < 4; 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