結果

問題 No.1638 Robot Maze
ユーザー sk461sk461
提出日時 2021-08-07 02:56:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 3,028 bytes
コンパイル時間 1,471 ms
コンパイル使用メモリ 123,516 KB
実行使用メモリ 814,824 KB
最終ジャッジ日時 2023-10-17 08:20:29
合計ジャッジ時間 4,490 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 MLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// #define _GLIBCXX_DEBUG
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

// #include <atcoder>
// using namespace atcoder;
// using mint = modint1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Bdouble = mp::number<mp::cpp_dec_float<32>>;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector v(h + 2, vector<char>(w + 2, '#'));
    ll u, d, r, l, k, p;
    cin >> u >> d >> r >> l >> k >> p;
    int xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    for (int i = 1; i < h + 1; i++) {
        for (int j = 1; j < w + 1; j++) {
            cin >> v[i][j];
        }
    }
    deque<vector<int>> dq;
    v[xt][yt] = 'g';
    dq.push_back({xs, ys, 0});
    vector<int> D[4] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
    ll cost = 0;
    bool fg = 0;
    while (!dq.empty()) {
        auto fr = dq.front();
        dq.pop_front();
        v[fr[0]][fr[1]] = '*';
        if (fr[2] == 1) {
            cost += p;
        }
        for (int i = 0; i < 4; i++) {
            if (v[fr[0] + D[i][0]][fr[1] + D[i][1]] == 'g') {
                fg = 1;
                break;
            } else if (v[fr[0] + D[i][0]][fr[1] + D[i][1]] == '.') {
                dq.push_front({fr[0] + D[i][0], fr[1] + D[i][1], 0});
            } else if (v[fr[0] + D[i][0]][fr[1] + D[i][1]] == '@') {
                dq.push_back({fr[0] + D[i][0], fr[1] + D[i][1], 1});
            }
        }
    }
    if (!fg) {
        cout << "No" << endl;
        return 0;
    }
    dq.clear();
    dq.push_back({xs, ys});
    while (!dq.empty()) {
        auto fr = dq.front();
        dq.pop_front();
        v[fr[0]][fr[1]] = '+';
        for (int i = 0; i < 4; i++) {
            if (v[fr[0] + D[i][0]][fr[1] + D[i][1]] == 'g') {
                if (i == 0) {
                    cost += u;
                } else if (i == 1) {
                    cost += d;
                } else if (i == 2) {
                    cost += r;
                } else {
                    cost += l;
                }
                break;
            } else if (v[fr[0] + D[i][0]][fr[1] + D[i][1]] == '*') {
                if (i == 0) {
                    cost += u;
                } else if (i == 1) {
                    cost += d;
                } else if (i == 2) {
                    cost += r;
                } else {
                    cost += l;
                }
                dq.push_back({fr[0] + D[i][0], fr[1] + D[i][1]});
            }
        }
    }
    if (cost <= k) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}
0