結果

問題 No.20 砂漠のオアシス
ユーザー TAISA_TAISA_
提出日時 2018-06-05 17:00:26
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 890 bytes
コンパイル時間 1,511 ms
コンパイル使用メモリ 148,148 KB
実行使用メモリ 814,632 KB
最終ジャッジ日時 2023-09-12 22:26:08
合計ジャッジ時間 6,402 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0