結果

問題 No.1638 Robot Maze
ユーザー kappybarkappybar
提出日時 2021-08-08 20:42:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,613 bytes
コンパイル時間 2,085 ms
コンパイル使用メモリ 180,100 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-19 21:21:00
合計ジャッジ時間 5,911 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 TLE -
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 #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define chmin(x,y) x = min((x),(y))
#define chmax(x,y) x = max((x),(y))
#define popcount(x) __builtin_popcount(x)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
const int INF = 1e9;
const long long LINF = 1e17;
const int MOD = 1000000007;
//const int MOD = 998244353;
const double PI = 3.14159265358979323846;

int dx[] = {-1,1,0,0};
int dy[] = {0,0,1,-1};

int main(){
    int h,w;
    cin >> h >> w;
    vector<ll> cost(4);
    rep(i,4) cin >> cost[i];
    ll k,p;
    cin >> k >> p;

    int xs,ys,xt,yt;
    cin >> xs >> ys >> xt >> yt;
    --xs;--ys;--xt;--yt;

    vector<string> maze(h);
    rep(i,h) cin >> maze[i];

    vector<vector<ll>> dist(h,vector<ll>(w,LINF));
    auto id = [&](int i,int j){return i+j*h;};

    priority_queue<pll,vector<pll>,greater<pll>> pq;
    pq.push(pll{id(xs,ys),0});
    while(!pq.empty()){
        int x = pq.top().first % h;
        int y = pq.top().first / h;
        ll d = pq.top().second;
        pq.pop();
        if(dist[x][y] < d) continue;
        dist[x][y] = d;

        rep(k,4){
            int new_x = x + dx[k];
            int new_y = y + dy[k];
            ll dis = d + cost[k];
            if(new_x < 0 || h <= new_x || new_y < 0 || w <= new_y) continue;
            if(maze[new_x][new_y] == '#') continue;
            if(maze[new_x][new_y] == '@') dis += p;

            pq.push(pll{id(new_x,new_y),dis});
        }
    }

    if(dist[xt][yt] <= k) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}
0