結果
| 問題 |
No.1638 Robot Maze
|
| コンテスト | |
| ユーザー |
harurun
|
| 提出日時 | 2021-06-23 02:20:20 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,017 bytes |
| コンパイル時間 | 5,739 ms |
| コンパイル使用メモリ | 124,572 KB |
| 最終ジャッジ日時 | 2025-01-22 11:43:48 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 TLE * 1 |
| other | RE * 41 TLE * 8 |
ソースコード
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
#define ll long long
typedef struct edge{
ll to;
ll cost;
}Edge;
typedef pair<int,int> P;
long long INF=1000000000000000000;
int V;
vector<Edge> G[250000];
long long d[250000];
void dijkstra(ll 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(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(P(d[e.to],e.to));
}
}
}
}
ostream& operator<<(ostream& os,vector<Edge> a){
for(Edge e:a){
os<<"to:"<<e.to<<",cots:"<<e.cost<<" ";
}
return os;
}
int main(){
ll H,W,U,D,R,L,K,xs,ys,xt,yt;
cin>>H>>W>>U>>D>>R>>L>>K;
V=H*W;//don't forget
vector<string> C(H);
for(int i=0;i<H;i++){
cin>>C.at(i);
C.at(i).append("#");
}
string s;
for(int i=0;i<W;i++)s.append("#");
C.push_back(s);
cin>>xs>>ys>>xt>>yt;
xs--;ys--;xt--;yt--;
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+1).at(j)=='.'){
//cerr<<i<<" "<<j<<"push_back tate\n";
G[W*i+j].push_back({W*(i+1)+j,D});
G[W*(i+1)+j].push_back({W*i+j,U});
}
if(C.at(i).at(j+1)=='.'){
//cerr<<i<<" "<<j<<"push_back yoko\n";
G[W*i+j].push_back({W*i+j+1,R});
G[W*i+j+1].push_back({W*i+j,L});
}
}
}
dijkstra(W*xs+ys);
// cerr<<W*xs+ys<<" "<<W*xt+yt<<" "<<d[W*xt+yt]<<endl;
// for(string i:C){
// cerr<<i<<endl;
// }
// for(int i=0;i<H;i++){
// for(int j=0;j<W;j++){
// cerr<<d[W*i+j]<<" ";
// }
// cerr<<endl;
// }
// for(int i=0;i<H;i++){
// for(int j=0;j<W;j++){
// cerr<<i<<" "<<j<<" "<<G[W*i+j]<<endl;
// }
// }
if(d[W*xt+yt]<=K)cout<<"Yes\n";
else cout<<"No\n";
return 0;
}
harurun