結果

問題 No.1638 Robot Maze
ユーザー yakkiyakki
提出日時 2021-08-06 21:58:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,448 bytes
コンパイル時間 1,458 ms
コンパイル使用メモリ 135,328 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 03:20:35
合計ジャッジ時間 2,992 ms
ジャッジサーバーID
(参考情報)
judge15 / 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 5 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 4 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 3 ms
4,348 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 AC 3 ms
4,348 KB
testcase_21 AC 3 ms
4,348 KB
testcase_22 AC 3 ms
4,348 KB
testcase_23 AC 3 ms
4,348 KB
testcase_24 AC 3 ms
4,348 KB
testcase_25 AC 3 ms
4,348 KB
testcase_26 AC 3 ms
4,348 KB
testcase_27 AC 3 ms
4,348 KB
testcase_28 AC 3 ms
4,348 KB
testcase_29 AC 3 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 5 ms
4,348 KB
testcase_33 AC 5 ms
4,348 KB
testcase_34 AC 5 ms
4,348 KB
testcase_35 AC 5 ms
4,348 KB
testcase_36 WA -
testcase_37 AC 5 ms
4,348 KB
testcase_38 AC 5 ms
4,348 KB
testcase_39 AC 5 ms
4,348 KB
testcase_40 AC 5 ms
4,348 KB
testcase_41 AC 5 ms
4,348 KB
testcase_42 AC 5 ms
4,348 KB
testcase_43 AC 5 ms
4,348 KB
testcase_44 AC 5 ms
4,348 KB
testcase_45 AC 5 ms
4,348 KB
testcase_46 AC 5 ms
4,348 KB
testcase_47 AC 5 ms
4,348 KB
testcase_48 AC 5 ms
4,348 KB
testcase_49 AC 4 ms
4,348 KB
testcase_50 AC 5 ms
4,348 KB
testcase_51 AC 5 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<ctime>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0)

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
//using mint = modint1000000007;

int dh[] = {-1,0,1,0};
int dw[] = {0,1,0,-1};

vector<ll> dijkstra(int n,int s, vector<vector<Pi>> &G){
    vector<ll> dist(n,LINF);
    vector<bool> visited(n,false);
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
    dist[s] = 0;
    visited[s] = true;
    q.push(make_pair(0,s));
    while(!q.empty()){
        auto p = q.top();
        ll p1 = p.first;
        int p2 = p.second;
        q.pop();
        if(p1 > dist[p2]) continue;
        visited[p2] = true;
        for(auto v : G[p2]){
            if(visited[v.first]) continue;
            if(dist[v.first] > dist[p2]+v.second){
                dist[v.first] = dist[p2]+v.second;
                q.push(make_pair(dist[v.first],v.first));
            }
        }
    }
    return dist;
}

int main(){
    int h,w; cin >> h >> w;
    ll u,d,r,l,k,p; cin >> u >> d >> r >> l >> k >> p;
    int xs,ys,xt,yt; cin >> xs >> ys >> xt >> yt;
    xs--; xt--; ys--; yt--;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    vector<vector<Pi>> G(h*w);
    rep(i,h)rep(j,w){
        if(s[i][j] == '#') continue;
        if(i < h-1){
            if(s[i+1][j] != '#'){
                G[i*w+j].emplace_back((i+1)*w+j,(s[i+1][j] == '.'?d:d+p));
                G[(i+1)*w+j].emplace_back(i*w+j,(s[i+1][j] == '.'?u:u+p));
            }
        }
        if(j < w-1){
            if(s[i][j+1] != '#'){
                G[i*w+j].emplace_back(i*w+j+1,(s[i][j+1] == '.'?r:r+p));
                G[i*w+j+1].emplace_back(i*w+j,(s[i][j+1] == '.'?l:l+p));
            }   
        }
    }
    vector<ll> dist = dijkstra(h*w,xs*w+ys,G);
    if(dist[xt*w+yt] <= k) cout << "Yes" << endl;
    else cout << "No" << endl;
}

0