結果

問題 No.20 砂漠のオアシス
ユーザー KodaiKodai
提出日時 2020-04-30 21:29:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 892 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 17,432 KB
最終ジャッジ日時 2023-08-22 17:44:05
合計ジャッジ時間 7,200 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,336 KB
testcase_01 AC 15 ms
8,164 KB
testcase_02 AC 15 ms
7,832 KB
testcase_03 AC 29 ms
8,280 KB
testcase_04 AC 67 ms
8,468 KB
testcase_05 AC 42 ms
10,412 KB
testcase_06 TLE -
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 #

import sys
sys.setrecursionlimit(10**6)
N, V, Ox, Oy = map(int, input().split())
L_list = [list(map(int, input().split())) for i in range(N)]

position_list = [[-float("inf") for i in range(N)] for j in range(N)]


def solve(i, j, v):

    position_list[i][j] = v
    if v <= 0:
        return 0
    if i == j == N - 1:
        print("YES")
        exit()
    if i == Oy - 1 and j == Ox - 1:
        v *= 2

    if i != 0 and position_list[i - 1][j] < v - L_list[i - 1][j]:
        solve(i - 1, j, v - L_list[i - 1][j])
    if i != N - 1 and position_list[i + 1][j] < v - L_list[i + 1][j]:
        solve(i + 1, j, v - L_list[i + 1][j])
    if j != 0 and position_list[i][j - 1] < v - L_list[i][j - 1]:
        solve(i, j - 1, v - L_list[i][j - 1])
    if j != N - 1 and position_list[i][j + 1] < v - L_list[i][j + 1]:
        solve(i, j + 1, v - L_list[i][j + 1])


solve(0, 0, V)
print("NO")
0