結果
| 問題 |
No.1638 Robot Maze
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-08 20:42:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,613 bytes |
| コンパイル時間 | 1,857 ms |
| コンパイル使用メモリ | 180,524 KB |
| 実行使用メモリ | 143,644 KB |
| 最終ジャッジ日時 | 2024-09-19 17:23:43 |
| 合計ジャッジ時間 | 5,537 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | TLE * 1 -- * 48 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define chmin(x,y) x = min((x),(y))
#define chmax(x,y) x = max((x),(y))
#define popcount(x) __builtin_popcount(x)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
const int INF = 1e9;
const long long LINF = 1e17;
const int MOD = 1000000007;
//const int MOD = 998244353;
const double PI = 3.14159265358979323846;
int dx[] = {-1,1,0,0};
int dy[] = {0,0,1,-1};
int main(){
int h,w;
cin >> h >> w;
vector<ll> cost(4);
rep(i,4) cin >> cost[i];
ll k,p;
cin >> k >> p;
int xs,ys,xt,yt;
cin >> xs >> ys >> xt >> yt;
--xs;--ys;--xt;--yt;
vector<string> maze(h);
rep(i,h) cin >> maze[i];
vector<vector<ll>> dist(h,vector<ll>(w,LINF));
auto id = [&](int i,int j){return i+j*h;};
priority_queue<pll,vector<pll>,greater<pll>> pq;
pq.push(pll{id(xs,ys),0});
while(!pq.empty()){
int x = pq.top().first % h;
int y = pq.top().first / h;
ll d = pq.top().second;
pq.pop();
if(dist[x][y] < d) continue;
dist[x][y] = d;
rep(k,4){
int new_x = x + dx[k];
int new_y = y + dy[k];
ll dis = d + cost[k];
if(new_x < 0 || h <= new_x || new_y < 0 || w <= new_y) continue;
if(maze[new_x][new_y] == '#') continue;
if(maze[new_x][new_y] == '@') dis += p;
pq.push(pll{id(new_x,new_y),dis});
}
}
if(dist[xt][yt] <= k) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}