結果

問題 No.1638 Robot Maze
ユーザー abc3abc3
提出日時 2021-08-06 23:28:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,314 bytes
コンパイル時間 5,134 ms
コンパイル使用メモリ 215,112 KB
実行使用メモリ 5,332 KB
最終ジャッジ日時 2023-10-17 05:16:32
合計ジャッジ時間 3,254 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 5 ms
5,332 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 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 AC 4 ms
4,348 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 WA -
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 2 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 WA -
testcase_24 AC 3 ms
4,348 KB
testcase_25 AC 3 ms
4,348 KB
testcase_26 WA -
testcase_27 AC 3 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 WA -
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 5 ms
5,064 KB
testcase_35 AC 5 ms
4,804 KB
testcase_36 WA -
testcase_37 AC 4 ms
4,776 KB
testcase_38 WA -
testcase_39 AC 5 ms
5,040 KB
testcase_40 AC 5 ms
4,776 KB
testcase_41 AC 6 ms
4,988 KB
testcase_42 AC 6 ms
4,992 KB
testcase_43 AC 6 ms
4,988 KB
testcase_44 AC 5 ms
4,904 KB
testcase_45 AC 4 ms
4,872 KB
testcase_46 AC 5 ms
5,040 KB
testcase_47 AC 5 ms
4,832 KB
testcase_48 AC 5 ms
5,068 KB
testcase_49 AC 4 ms
4,776 KB
testcase_50 AC 5 ms
4,868 KB
testcase_51 AC 5 ms
5,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

   #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    typedef unsigned long long ull;
    using P=pair<ll,ll>;
    const ll INF=1e18;
    const int mod=998244353;
    
    struct edge{
      int to;
      ll w;
      edge(int to,ll w):to(to),w(w){}
    };
    using Graph=vector<vector<edge>>;
    
    int n;
    ll h,w,k,p,xs,ys,xt,yt;
    
    int toid(int i,int j){return i*w+j;}
    
    ll dijkstra(int s,Graph G){
      vector<ll> dist(n,INF);
      dist[s]=0;
      priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>>q;
      q.push({dist[s],s});
      while(!q.empty()){
        int v=q.top().second;
        ll d=q.top().first;
        q.pop();
        if(d>dist[v]){continue;}
        for(auto e:G[v]){
          if(chmin(dist[e.to],dist[v]+e.w)){
            q.push({dist[e.to],e.to});
          }
        }
      }
      return dist[toid(yt,xt)];
    }

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

    void solve(){
        cin>>h>>w;
        vector<ll>s(4);
        rep(i,4){cin>>s[i];}
        
        cin>>k>>p>>xs>>ys>>xt>>yt;
        xs--;ys--;xt--;yt--;

        n=h*w;
        Graph G(n);

        rep(i,h){
            rep(j,w){
                cin>>c[i][j];
            }
        }
        
        rep(i,h){
            rep(j,w){
                if(c[i][j]=='#'){continue;}
                rep(k,4){
                    int ni=i+dy[k],nj=j+dx[k];
                    if(ni>=0&&ni<h&&nj>=0&&nj<w&&c[ni][nj]!='#'){
                        ll cost=s[k]+(c[ni][nj]=='@'?p:0);
                        G[toid(i,j)].push_back(edge(toid(ni,nj),cost));
                    }
                }
            }
        }
        ll dist=dijkstra(toid(ys,xs),G);
        if(dist<=k){cout<<"Yes"<<endl;}
        else{cout<<"No"<<endl;}
    }

    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        solve();  

        return 0;
    }
0