結果

問題 No.20 砂漠のオアシス
ユーザー KodaiKodai
提出日時 2020-04-30 21:27:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 852 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 10,808 KB
実行使用メモリ 10,592 KB
最終ジャッジ日時 2023-08-22 17:40:16
合計ジャッジ時間 6,468 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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