結果

問題 No.1638 Robot Maze
ユーザー karinohitokarinohito
提出日時 2021-08-06 21:40:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,685 bytes
コンパイル時間 3,041 ms
コンパイル使用メモリ 188,796 KB
実行使用メモリ 401,612 KB
最終ジャッジ日時 2023-10-17 02:57:19
合計ジャッジ時間 6,853 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 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 <atcoder/all>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
//using namespace atcoder;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<ll>>;
Graph G;
vll E;
vector<bool> seen;
ll k = 0;
void dfs(int v) {
	seen[v] = true; // v を訪問済にする

	// v から行ける各頂点 next_v について
	E[v] = k;
	for (auto next_v : G[v]) {
		if (seen[next_v]) continue; // next_v が探索済だったらスルー
		k++;
		dfs(next_v); // 再帰的に探索
	}
	E[v] = k - E[v];
}

int main() {
	ll H,W;
	cin>>H>>W;
	ll U,D,R,L,K,P;
	cin>>U>>D>>R>>L>>K>>P;
	priority_queue<tuple<ll,ll,ll>,vector<tuple<ll,ll,ll>>,greater<tuple<ll,ll,ll>>> Q;
	ll XS,YS,XT,YT;
	cin>>XS>>YS>>XT>>YT;
	XS--;XT--;YS--;YT--;
	vector<vll> C(H,vll(W));
	rep(h,H){
		string S;
		cin>>S;
		rep(w,W){
			if(S[w]=='.')C[h][w]=0;
			else if(S[w]=='@')C[h][w]=1;
			else C[h][w]=2;
		}


	}


	vector<vector<bool>> seen(H,vector<bool> (W,false));
	vector<vll> dist(H,vll(W,1e18));
	dist[XS][YS]=0;
	Q.push(make_tuple(0,XS,YS));
	vll dx={1,-1,0,0};
	vll dy={0,0,1,-1};
	vll dp={D,U,R,L};
	while(!Q.empty()){
		auto p=Q.top();
		Q.pop();
		ll c=get<0>(p);
		ll y=get<2>(p);
		ll x=get<1>(p);
		rep(i,4){
			ll nx=x+dx[i];
			ll ny=y+dy[i];
			if(nx<0||x+dx[i]>=H||y+dy[i]<0||y+dy[i]>=W)continue;
			if(C[nx][ny]==2)continue;
			ll HH=0;
			if(C[nx][ny]==1)HH+=P;
			if(dist[nx][ny]<dist[x][y]+HH+dp[i])continue;
			dist[nx][ny]=dist[x][y]+HH+dp[i];
			Q.push(make_tuple(dist[nx][ny],nx,ny));
		}
	}
	if(dist[XT][YT]<=K)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}
0