結果

問題 No.1638 Robot Maze
ユーザー harurunharurun
提出日時 2021-06-27 02:39:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,622 bytes
コンパイル時間 1,080 ms
コンパイル使用メモリ 89,984 KB
実行使用メモリ 7,008 KB
最終ジャッジ日時 2023-10-17 02:24:16
合計ジャッジ時間 2,881 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,128 KB
testcase_01 AC 3 ms
6,128 KB
testcase_02 AC 3 ms
6,124 KB
testcase_03 AC 6 ms
7,008 KB
testcase_04 AC 3 ms
6,132 KB
testcase_05 AC 3 ms
6,132 KB
testcase_06 AC 3 ms
6,132 KB
testcase_07 AC 3 ms
6,132 KB
testcase_08 AC 3 ms
6,132 KB
testcase_09 AC 3 ms
6,132 KB
testcase_10 AC 3 ms
6,132 KB
testcase_11 AC 3 ms
6,132 KB
testcase_12 AC 3 ms
6,132 KB
testcase_13 AC 5 ms
6,132 KB
testcase_14 AC 5 ms
6,604 KB
testcase_15 AC 4 ms
6,440 KB
testcase_16 AC 4 ms
6,440 KB
testcase_17 AC 4 ms
6,440 KB
testcase_18 AC 3 ms
6,440 KB
testcase_19 WA -
testcase_20 AC 6 ms
6,452 KB
testcase_21 AC 4 ms
6,460 KB
testcase_22 AC 4 ms
6,460 KB
testcase_23 AC 4 ms
6,460 KB
testcase_24 WA -
testcase_25 AC 4 ms
6,460 KB
testcase_26 AC 4 ms
6,460 KB
testcase_27 AC 4 ms
6,460 KB
testcase_28 AC 4 ms
6,460 KB
testcase_29 AC 4 ms
6,460 KB
testcase_30 AC 3 ms
6,128 KB
testcase_31 AC 3 ms
6,128 KB
testcase_32 AC 6 ms
6,708 KB
testcase_33 AC 6 ms
6,768 KB
testcase_34 AC 6 ms
6,892 KB
testcase_35 AC 6 ms
6,760 KB
testcase_36 WA -
testcase_37 AC 5 ms
6,712 KB
testcase_38 AC 5 ms
6,712 KB
testcase_39 AC 6 ms
6,876 KB
testcase_40 AC 6 ms
6,728 KB
testcase_41 AC 6 ms
6,780 KB
testcase_42 AC 6 ms
6,784 KB
testcase_43 AC 6 ms
6,788 KB
testcase_44 AC 6 ms
6,816 KB
testcase_45 AC 6 ms
6,800 KB
testcase_46 AC 6 ms
6,856 KB
testcase_47 AC 7 ms
6,780 KB
testcase_48 AC 6 ms
6,892 KB
testcase_49 AC 6 ms
6,712 KB
testcase_50 AC 24 ms
6,908 KB
testcase_51 AC 7 ms
6,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
#include <queue>
#include <utility>
#include <string>
using namespace std;

#define ll long long

typedef struct edge{
	ll to;
	ll cost;
}Edge;
typedef pair<int,int> Pii;

long long INF=1000000000000000000;
int V;
vector<Edge> G[100000];
long long d[100000];

void dijkstra(int s){
  priority_queue<Pii,vector<Pii>,greater<Pii>> que;
	fill(d,d+V,INF);
	d[s]=0;
	que.push(Pii(0,s));
	while(!que.empty()){
		Pii p=que.top();que.pop();
		int v=p.second;
		if(d[v]<p.first)continue;
		for(unsigned int i=0;i<G[v].size();i++){
		  Edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost){
			  d[e.to]=d[v]+e.cost;
				que.push(Pii(d[e.to],e.to));
			}
		}
	}
}

ostream& operator<<(ostream& os,vector<Edge>& a){
  for(Edge i:a){
    os<<"to:"<<i.to<<",cost:"<<i.cost<<" ";
  }
  return os;
}

int main(){
  ll H,W,U,D,R,L,K,P,xs,ys,xt,yt;
  cin>>H>>W>>U>>D>>R>>L>>K>>P>>xs>>ys>>xt>>yt;
  //cerr<<"P:"<<P<<endl;
  V=H*W;//また忘れてた
  U*=2;D*=2;R*=2;L*=2;K*=2;
  xs--;ys--;xt--;yt--;
  string s="";
  vector<string>C(H);
  for(int i=0;i<H;i++){
    cin>>C.at(i);
    C.at(i).append("#");
  }
  for(int i=0;i<W;i++)s.append("#");
  C.push_back(s);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(C.at(i).at(j)=='#')continue;
      if(C.at(i).at(j)=='@'){
        if(C.at(i+1).at(j)=='.'){
          G[W*i+j].push_back({W*(i+1)+j,P+D});
          G[W*(i+1)+j].push_back({W*i+j,P+U});
        }else if(C.at(i+1).at(j)=='@'){
          G[W*i+j].push_back({W*(i+1)+j,2*P+D});
          G[W*(i+1)+j].push_back({W*i+j,2*P+U});
        }
        if(C.at(i).at(j+1)=='.'){
          G[W*i+j].push_back({W*i+j+1,P+R});
          G[W*i+j+1].push_back({W*i+j,P+L});
        }else if(C.at(i).at(j+1)=='@'){
          G[W*i+j].push_back({W*i+j+1,P+R});
          G[W*i+j+1].push_back({W*i+j,P+L});
        }
      }else{
        if(C.at(i+1).at(j)=='.'){
          G[W*i+j].push_back({W*(i+1)+j,D});
          G[W*(i+1)+j].push_back({W*i+j,U});
        }else if(C.at(i+1).at(j)=='@'){
          G[W*i+j].push_back({W*(i+1)+j,P+D});
          G[W*(i+1)+j].push_back({W*i+j,P+U});
        }
        if(C.at(i).at(j+1)=='.'){
          G[W*i+j].push_back({W*i+j+1,R});
          G[W*i+j+1].push_back({W*i+j,L});
        }else if(C.at(i).at(j+1)=='@'){
          G[W*i+j].push_back({W*i+j+1,P+R});
          G[W*i+j+1].push_back({W*i+j,P+L});
        }
      }
    }
  }
  dijkstra(W*xs+ys);
  if(d[W*xt+yt]<=K)cout<<"Yes\n";
  else cout<<"No\n";
  cerr<<"ans:"<<d[W*xt+yt]/2<<endl;
  // for(int i=0;i<V;i++){
  //   cout<<"i:"<<i<<endl;
  //   cout<<G[i]<<endl;
  //   cout<<endl;
  // }
  return 0;
}
0