結果

問題 No.20 砂漠のオアシス
ユーザー kaffelunkaffelun
提出日時 2017-10-05 20:01:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 322 ms / 5,000 ms
コード長 783 bytes
コンパイル時間 1,621 ms
コンパイル使用メモリ 158,428 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 07:51:44
合計ジャッジ時間 2,572 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 5 ms
5,376 KB
testcase_05 AC 7 ms
5,376 KB
testcase_06 AC 12 ms
5,376 KB
testcase_07 AC 322 ms
5,376 KB
testcase_08 AC 55 ms
5,376 KB
testcase_09 AC 166 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 15 ms
5,376 KB
testcase_15 AC 8 ms
5,376 KB
testcase_16 AC 31 ms
5,376 KB
testcase_17 AC 14 ms
5,376 KB
testcase_18 AC 30 ms
5,376 KB
testcase_19 AC 26 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define INF 10000000
using namespace std;
int dp[200][200];
int N, V;
int L[200][200];
int Ox, Oy;
void recursive(int y, int x, int life) {
	if(dp[y][x] >= life) return;
	dp[y][x] = life;
	int d[4][2] = {{1,0}, {-1, 0}, {0, 1}, {0, -1}};
	int ky, kx;
	int retval = 0;
	for(int i = 0; i < 4; i++) {
		ky = y + d[i][0], kx = x + d[i][1];
		if(ky < 0 || N <= ky || kx < 0 || N <= kx) continue;
		recursive(ky, kx, life - L[ky][kx]);
	}
}
int main() {
	cin >> N >> V >> Ox >> Oy;
	Oy--, Ox--;
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < N; j++) {
			cin >> L[i][j];
			dp[i][j] = 0;
		}
	}
	recursive(0, 0, V);
	if(dp[Oy][Ox] > 0) recursive(Oy, Ox, 2 * dp[Oy][Ox]);
	if(dp[N - 1][N - 1] > 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}
0