結果

問題 No.1638 Robot Maze
ユーザー NanashimaNanashima
提出日時 2021-08-06 22:24:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,347 bytes
コンパイル時間 1,747 ms
コンパイル使用メモリ 179,196 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 03:48:11
合計ジャッジ時間 3,425 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define all(a)  (a).begin(),(a).end()
#define rall(a)  (a).rbegin(),(a).rend()
typedef long long ll;
typedef pair<ll,ll> pl;
typedef tuple<ll,ll,ll> tupl;

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

int main()
{
    int h,w;
    cin >> h >> w;
    int u,d,r,l;
    ll k,p;
    cin >> u >> d >> r >> l >> k >> p;
    int sx,sy,gx,gy;
    cin >> sx >> sy >> gx >> gy;
    sx--; sy--; gx--; gy--;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    queue<pair<int,int>> q;
    vector<vector<ll>> dist(h,vector<ll> (w,INF));
    dist[sx][sy]=0; 
    q.push({sx,sy});
    while(!q.empty()) {
        int x=q.front().first;
        int y=q.front().second;
        q.pop();
        rep(i,4) {
            int nx=x+dx[i],ny=y+dy[i];
            if(nx<0||nx>=h||ny<0||ny>=w) continue;
            if(s[nx][ny]=='#') continue;
            ll cur=dist[x][y];
            if(i==0) cur+=u;
            if(i==1) cur+=d;
            if(i==2) cur+=r;
            if(i==3) cur+=l;
            if(s[nx][ny]=='@') cur+=p;
            if(dist[nx][ny]>cur) dist[nx][ny]=cur;
            else continue;
            q.push({nx,ny});
        }
    }
    if(dist[gx][gy]<=k) cout << "Yes" << endl;
    else cout << "No" << endl; 
    return 0;
}
0