結果

問題 No.1638 Robot Maze
ユーザー sk461sk461
提出日時 2021-08-07 03:31:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,156 bytes
コンパイル時間 1,510 ms
コンパイル使用メモリ 130,560 KB
実行使用メモリ 814,300 KB
最終ジャッジ日時 2023-10-17 08:51:12
合計ジャッジ時間 6,107 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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,964 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
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 WA -
testcase_13 AC 2 ms
4,348 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 4 ms
4,452 KB
testcase_17 AC 4 ms
4,452 KB
testcase_18 AC 3 ms
4,420 KB
testcase_19 MLE -
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>>;

const ll MAX = 1e18;

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});
    vector<int> D[4] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
    bool fg = 0;
    vector cnt(h + 2, vector<vector<ll>>(w + 2, {MAX, MAX, MAX, MAX, MAX}));
    cnt[xs][ys] = {0, 0, 0, 0, 0};
    while (!dq.empty()) {
        auto fr = dq.front();
        dq.pop_front();
        v[fr[0]][fr[1]] = '*';
        for (int i = 0; i < 4; i++) {
            int a = fr[0] + D[i][0];
            int b = fr[1] + D[i][1];
            if (v[a][b] == 'g') {
                fg = 1;
                cnt[a][b] = cnt[fr[0]][fr[1]];
                if (i == 0) {
                    cnt[a][b][0]++;
                } else if (i == 1) {
                    cnt[a][b][1]++;
                } else if (i == 2) {
                    cnt[a][b][2]++;
                } else {
                    cnt[a][b][3]++;
                }
                break;
            } else if (v[a][b] == '.') {
                dq.push_front({a, b});
                cnt[a][b] = cnt[fr[0]][fr[1]];
                if (i == 0) {
                    cnt[a][b][0]++;
                } else if (i == 1) {
                    cnt[a][b][1]++;
                } else if (i == 2) {
                    cnt[a][b][2]++;
                } else {
                    cnt[a][b][3]++;
                }
            } else if (v[a][b] == '@') {
                dq.push_back({a, b});
                cnt[a][b] = cnt[fr[0]][fr[1]];
                cnt[a][b][4]++;
                if (i == 0) {
                    cnt[a][b][0]++;
                } else if (i == 1) {
                    cnt[a][b][1]++;
                } else if (i == 2) {
                    cnt[a][b][2]++;
                } else {
                    cnt[a][b][3]++;
                }
            }
        }
    }
    if (!fg) {
        cout << "No" << endl;
    } else if (cnt[xt][yt][0] * u + cnt[xt][yt][1] * d + cnt[xt][yt][2] * r + cnt[xt][yt][3] * l + cnt[xt][yt][4] * p <= k) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}   
0