結果

問題 No.20 砂漠のオアシス
ユーザー kaffelunkaffelun
提出日時 2017-10-05 19:55:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 770 bytes
コンパイル時間 1,292 ms
コンパイル使用メモリ 158,428 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 07:51:30
合計ジャッジ時間 2,916 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 WA -
testcase_04 AC 7 ms
6,940 KB
testcase_05 WA -
testcase_06 AC 14 ms
6,944 KB
testcase_07 WA -
testcase_08 AC 70 ms
6,940 KB
testcase_09 AC 214 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 WA -
testcase_12 AC 4 ms
6,944 KB
testcase_13 AC 6 ms
6,940 KB
testcase_14 AC 18 ms
6,944 KB
testcase_15 AC 10 ms
6,944 KB
testcase_16 AC 38 ms
6,940 KB
testcase_17 AC 18 ms
6,940 KB
testcase_18 AC 37 ms
6,944 KB
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
	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