結果
| 問題 |
No.1638 Robot Maze
|
| コンテスト | |
| ユーザー |
riano
|
| 提出日時 | 2021-08-06 21:38:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 2,198 bytes |
| コンパイル時間 | 1,806 ms |
| コンパイル使用メモリ | 186,468 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-17 01:29:25 |
| 合計ジャッジ時間 | 3,208 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:63:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
63 | auto[c,x,y] = p;
| ^
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define Pr pair<ll,ll>
#define Tp tuple<ll,ll,ll>
using Graph = vector<vector<int>>;
#define double long double
const ll mod = 1000000007;
//dfs
//s:始点 i:dfs回数 t:始点からの距離
vector<int> vis; int t;
vector<int> depth;
//探索範囲を距離L以下に制限する場合
int L;
vector<ll> cnt(100001,0);
void dfs(Graph &G, int s,int i){
int ti = t;
t++;
for(int nx:G[s]){
if(t>=L) break;
if(vis[nx]==i) continue;
depth[nx] = depth[s] + 1;
vis[nx] = i;
dfs(G,nx,i);
}
t++;
cnt[s] = (t-ti)/2;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll H,W; cin >> H >> W;
ll U,D,R,L,K,P; cin >> U >> D >> R >> L >> K >> P;
ll cost[H][W];
rep(i,H){
rep(j,W) cost[i][j] = 2e18;
}
ll xs,xt,ys,yt; cin >> xs >> ys >> xt >> yt;
cost[xs-1][ys-1] = 0;
char g[H][W];
rep(i,H){
rep(j,W) cin >> g[i][j];
}
//Dijkstra (普通のダイクストラ)
priority_queue<Tp, vector<Tp>, greater<Tp>> go;
ll inf = 2e18;
go.push(make_tuple(0,xs-1,ys-1));
Tp p;
vector<pair<int,int>> step;
step.push_back(make_pair(-1,0));
step.push_back(make_pair(0,-1));
step.push_back(make_pair(1,0));
step.push_back(make_pair(0,1));
vector<ll> cs = {U,L,D,R};
while(!go.empty()){
p = go.top(); go.pop();
auto[c,x,y] = p;
if(c>cost[x][y]) continue;
rep(i,4){
ll z = x+step[i].first;
ll w = y+step[i].second;
if(0>z||z>=H||0>w||W<=w) continue;
if(g[z][w]=='#') continue;
ll cc = cost[x][y];
if(g[z][w]=='@') cc += P;
if(cc+cs[i]<cost[z][w]){
cost[z][w] = cc+cs[i];
go.push(make_tuple(cost[z][w],z,w));
// cout << z << " " << w << endl;
// cout << cost[z][w] << endl;
}
}
}
//cout << cost[xt-1][yt-1] << endl;
string ans = "Yes";
if(cost[xt-1][yt-1]>K) ans = "No";
cout << ans << endl;
}
riano