結果

問題 No.323 yuki国
ユーザー t98slidert98slider
提出日時 2023-03-10 15:52:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 1,002 bytes
コンパイル時間 1,824 ms
コンパイル使用メモリ 184,624 KB
実行使用メモリ 4,440 KB
最終ジャッジ日時 2023-10-18 06:44:48
合計ジャッジ時間 5,388 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 5 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 94 ms
4,440 KB
testcase_09 AC 94 ms
4,396 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 97 ms
4,396 KB
testcase_14 AC 95 ms
4,396 KB
testcase_15 AC 52 ms
4,408 KB
testcase_16 AC 94 ms
4,412 KB
testcase_17 AC 111 ms
4,408 KB
testcase_18 AC 35 ms
4,348 KB
testcase_19 AC 69 ms
4,348 KB
testcase_20 AC 133 ms
4,428 KB
testcase_21 AC 137 ms
4,428 KB
testcase_22 AC 138 ms
4,428 KB
testcase_23 AC 135 ms
4,428 KB
testcase_24 AC 59 ms
4,404 KB
testcase_25 AC 58 ms
4,404 KB
testcase_26 AC 115 ms
4,404 KB
testcase_27 AC 117 ms
4,408 KB
testcase_28 AC 114 ms
4,396 KB
testcase_29 AC 106 ms
4,396 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 3 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, a, sy, sx, b, gy, gx;
    cin >> h >> w >> a >> sy >> sx >> b >> gy >> gx;
    vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(2001)));
    vector<string> A(h);
    for(auto &&s : A) cin >> s;
    queue<tuple<int,int,int>> nxt;
    dp[sy][sx][a] = true;
    nxt.emplace(sy, sx, a);
    int y, x, v;
    while(!nxt.empty()){
        tie(y, x, v) = nxt.front();
        nxt.pop();
        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) continue;
            int nv = v + (A[ny][nx] == '*' ? 1 : -1);
            if(nv <= 0 || nv >= 2001) continue;
            if(dp[ny][nx][nv]) continue;
            dp[ny][nx][nv] = true;
            nxt.emplace(ny, nx, nv);
        }
    }
    cout << (dp[gy][gx][b] ? "Yes" : "No") << '\n';
}
0