結果

問題 No.1638 Robot Maze
ユーザー trineutrontrineutron
提出日時 2021-08-06 21:42:00
言語 C++23(draft)
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,597 bytes
コンパイル時間 3,674 ms
コンパイル使用メモリ 264,708 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 02:58:45
合計ジャッジ時間 4,606 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 4 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 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 2 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 AC 3 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 3 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 3 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 4 ms
4,348 KB
testcase_33 AC 5 ms
4,348 KB
testcase_34 AC 4 ms
4,348 KB
testcase_35 AC 4 ms
4,348 KB
testcase_36 AC 4 ms
4,348 KB
testcase_37 AC 4 ms
4,348 KB
testcase_38 AC 4 ms
4,348 KB
testcase_39 AC 4 ms
4,348 KB
testcase_40 AC 4 ms
4,348 KB
testcase_41 AC 4 ms
4,348 KB
testcase_42 AC 4 ms
4,348 KB
testcase_43 AC 4 ms
4,348 KB
testcase_44 AC 4 ms
4,348 KB
testcase_45 AC 4 ms
4,348 KB
testcase_46 AC 5 ms
4,348 KB
testcase_47 AC 4 ms
4,348 KB
testcase_48 AC 4 ms
4,348 KB
testcase_49 AC 4 ms
4,348 KB
testcase_50 WA -
testcase_51 AC 4 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using vertex = tuple<int64_t, int, int>;

constexpr int64_t inf = 1e18;
vector<int> dx{-1, 1, 0, 0}, dy{0, 0, 1, -1}, cost(4);

int main()
{
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < 4; i++)
    {
        cin >> cost.at(i);
    }
    int64_t k, p;
    cin >> k >> p;
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    sx--;
    sy--;
    tx--;
    ty--;
    vector<string> c(h);
    for (auto &&s : c)
    {
        cin >> s;
    }
    vector total(h, vector<int64_t>(w, inf));
    priority_queue<vertex, vector<vertex>, greater<vertex>> q;
    q.emplace(0, sx, sy);
    while (not q.empty())
    {
        auto [d0, x, y] = q.top();
        q.pop();
        if (d0 >= total.at(x).at(y))
        {
            continue;
        }
        total.at(x).at(y) = d0;
        for (int i = 0; i < 4; i++)
        {
            int x_next = x + dx.at(i), y_next = y + dy.at(i), d_next = d0 + cost.at(i);
            if (x_next < 0 or h <= x_next or y_next < 0 or w <= y_next)
            {
                continue;
            }
            if (c.at(x_next).at(y_next) == '#')
            {
                continue;
            }
            if (c.at(x_next).at(y_next) == '@')
            {
                d_next += p;
            }
            if (d_next >= total.at(x_next).at(y_next))
            {
                continue;
            }
            q.emplace(d_next, x_next, y_next);
        }
    }
    if (total.at(tx).at(ty) <= k)
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }
    return 0;
}
0