結果

問題 No.20 砂漠のオアシス
ユーザー kaffelunkaffelun
提出日時 2017-10-05 20:01:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 382 ms / 5,000 ms
コード長 783 bytes
コンパイル時間 1,471 ms
コンパイル使用メモリ 144,680 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-10 14:49:38
合計ジャッジ時間 2,970 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 6 ms
4,380 KB
testcase_05 AC 7 ms
4,376 KB
testcase_06 AC 12 ms
4,380 KB
testcase_07 AC 382 ms
4,380 KB
testcase_08 AC 65 ms
4,376 KB
testcase_09 AC 190 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 16 ms
4,380 KB
testcase_15 AC 9 ms
4,384 KB
testcase_16 AC 34 ms
4,380 KB
testcase_17 AC 16 ms
4,384 KB
testcase_18 AC 32 ms
4,380 KB
testcase_19 AC 31 ms
4,380 KB
testcase_20 AC 3 ms
4,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