結果
| 問題 |
No.1638 Robot Maze
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-06 21:30:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 911 bytes |
| コンパイル時間 | 690 ms |
| コンパイル使用メモリ | 78,428 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-17 01:21:43 |
| 合計ジャッジ時間 | 2,085 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 |
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
9 | main()
| ^~~~
ソースコード
#include<iostream>
#include<queue>
using namespace std;
int H,W,U,D,R,L,P;
long K;
int sx,sy,gx,gy;
string S[100];
long dp[100][100];
main()
{
cin>>H>>W>>U>>D>>R>>L>>K>>P>>sx>>sy>>gx>>gy;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int dc[4]={R,D,L,U};
sx--,sy--,gx--,gy--;
for(int i=0;i<H;i++)cin>>S[i];
for(int i=0;i<H;i++)for(int j=0;j<W;j++)dp[i][j]=K+1;
dp[sx][sy]=0;
priority_queue<pair<long,pair<int,int> > >Q;
Q.push(make_pair(0,make_pair(sx,sy)));
while(!Q.empty())
{
long c=-Q.top().first;
int x=Q.top().second.first,y=Q.top().second.second;
Q.pop();
if(dp[x][y]<c)continue;
for(int r=0;r<4;r++)
{
int tx=x+dx[r],ty=y+dy[r];
if(tx<0||ty<0||tx>=H||ty>=W||S[tx][ty]=='#')continue;
long nc=c+dc[r];
if(S[tx][ty]=='@')nc+=P;
if(dp[tx][ty]>nc)
{
dp[tx][ty]=nc;
Q.push(make_pair(-nc,make_pair(tx,ty)));
}
}
}
cout<<(dp[gx][gy]>K?"No":"Yes")<<endl;
}