結果
| 問題 | No.20 砂漠のオアシス |
| コンテスト | |
| ユーザー |
TAISA_
|
| 提出日時 | 2018-06-05 17:00:26 |
| 言語 | C++11(廃止可能性あり) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 890 bytes |
| 記録 | |
| コンパイル時間 | 1,355 ms |
| コンパイル使用メモリ | 164,552 KB |
| 実行使用メモリ | 814,672 KB |
| 最終ジャッジ日時 | 2024-06-30 09:55:58 |
| 合計ジャッジ時間 | 5,546 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | MLE * 1 -- * 20 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
struct pos{int x,y,h;};
int main(){
int n,v,ox,oy;cin>>n>>v>>ox>>oy;ox--;oy--;
int c[210][210];
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
cin>>c[i][j];
}
}
queue<pos> q;
q.push({0,0,v});
int ans=0;
while(!q.empty()){
pos p=q.front();
if(p.x==n-1&&p.y==n-1){
ans=p.h;
break;
}
if(p.x+1<n){
int nh=p.h+c[p.y][p.x+1];
if(p.x+1==ox&&p.y==oy){
nh*=2;
}
q.push({p.x+1,p.y,nh});
}
if(p.y+1<n){
int nh=p.h+c[p.y+1][p.x];
if(p.x==ox&&p.y+1==oy){
nh*=2;
}
q.push({p.x,p.y+1,nh});
}
}
if(ans<0){
cout<<"NO"<<endl;
}else{
cout<<"YES"<<endl;
}
return 0;
}
TAISA_