結果

問題 No.1638 Robot Maze
ユーザー madokamadoka
提出日時 2021-08-07 07:43:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 3,046 bytes
コンパイル時間 2,551 ms
コンパイル使用メモリ 169,704 KB
実行使用メモリ 4,700 KB
最終ジャッジ日時 2023-10-17 13:26:15
合計ジャッジ時間 5,298 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 6 ms
4,700 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
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 WA -
testcase_15 WA -
testcase_16 AC 3 ms
4,348 KB
testcase_17 WA -
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 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 3 ms
4,348 KB
testcase_29 WA -
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 5 ms
4,404 KB
testcase_33 WA -
testcase_34 AC 6 ms
4,588 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 5 ms
4,408 KB
testcase_38 WA -
testcase_39 AC 6 ms
4,572 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 6 ms
4,532 KB
testcase_43 AC 6 ms
4,532 KB
testcase_44 AC 6 ms
4,532 KB
testcase_45 AC 4 ms
4,532 KB
testcase_46 AC 6 ms
4,552 KB
testcase_47 AC 5 ms
4,532 KB
testcase_48 AC 6 ms
4,596 KB
testcase_49 AC 5 ms
4,404 KB
testcase_50 AC 6 ms
4,532 KB
testcase_51 AC 6 ms
4,596 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:141:21: warning: iteration 10004 invokes undefined behavior [-Waggressive-loop-optimizations]
  141 |                 d[i]=INF;
      |                     ^
main.cpp:140:21: note: within this loop
  140 |         for(ll i=1;i<=10005;i++){
      |                    ~^~~~~~~

ソースコード

diff #

/********include********/
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
//#include <atcoder/all>

/***/
//#include <iomanip>
//#include <cmath>
#include <bits/stdc++.h>



#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define rrep(i,x) for(long long i=x-1;i>=0;i--)
#define rrepn(i,x) for(long long i=x;i>1;i--)
#define REP(i,n,x) for(long long i=n;i<x;i++)
#define REPN(i,n,x) for(long long i=n+1;i<x;i++)

#define pr printf
#define re return
#define mod 1000000007
//#define mod 998244353
#define inf  INT_MAX//19桁
#define INF 1e18+5//19桁
const double PI=3.14159265358979323846;
#define fi first
#define se second
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define all(x) (x).begin(),(x).end()

typedef long long int ll;
typedef pair<long long, long long> P;

struct edge{double to, cost;};
ll V;
#define MAX_V 10005
//vector<edge>G[MAX_V];
vector<edge>G[MAX_V];
double d[MAX_V];

	


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

vector<string> masu(10005);


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll H,W;
	ll U,D,R,L,K,P;
	
	ll sh,sw,th,tw;
	cin>>H>>W;
	cin>>U>>D>>R>>L>>K>>P;
	cin>>sw>>sh>>tw>>th;
	for(ll i=1;i<=H;i++){
		cin>>masu[i];
	}
	for(ll i=1;i<=H*W;i++){
		if(masu[(i-1)/W+1][(i)%(W+1)]=='#')continue;
		if(i%W!=1){
			if(masu[(i-1)/W+1][(i-1)%(W+1)]=='.'){
				G[i].push_back({(double)i-1,(double)L});
			}
			else if(masu[(i-1)/W+1][(i-1)%(W+1)]=='@'){
				G[i].push_back({(double)i-1,(double)P});
			}
		}
		if(i%W!=0){
			if(masu[(i-1)/W+1][(i+1)%(W+1)]=='.'){
				G[i].push_back({(double)i+1,(double)R});
			}
			else if(masu[(i-1)/W+1][(i+1)%(W+1)]=='@'){
				G[i].push_back({(double)i+1,(double)P});
			}
		}
		if(i-H>0){
			if(masu[(i-H-1)/W+1][(i)%(W+1)]=='.'){
				G[i].push_back({(double)i-H,(double)U});
			}
			else if(masu[(i-H-1)/W+1][(i)%(W+1)]=='@'){
				G[i].push_back({(double)i-H,(double)P});
			}
		}
		if(i+H<=H*W){
			if(masu[(i+H-1)/W+1][(i)%(W+1)]=='.'){
				G[i].push_back({(double)i+H,(double)D});
			}
			else if(masu[(i+H-1)/W+1][(i)%(W+1)]=='@'){
				G[i].push_back({(double)i+H,(double)P});
			}
		}
	}
	for(ll i=1;i<=10005;i++){
		d[i]=INF;
	}

	back_pri_dijkstra((sh-1)*W+sw);
	if(d[(th-1)*W+tw]<=K){
		cout<<"Yes"<<"\n";
	}
	else{
		cout<<"No"<<"\n";
	}

	re 0;
    
}
0