結果

問題 No.20 砂漠のオアシス
ユーザー KodaiKodai
提出日時 2020-04-30 21:46:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,425 bytes
コンパイル時間 403 ms
コンパイル使用メモリ 10,960 KB
実行使用メモリ 10,444 KB
最終ジャッジ日時 2023-08-22 18:12:23
合計ジャッジ時間 13,633 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,324 KB
testcase_01 AC 17 ms
8,408 KB
testcase_02 AC 18 ms
8,044 KB
testcase_03 AC 33 ms
8,444 KB
testcase_04 AC 74 ms
8,516 KB
testcase_05 AC 45 ms
10,344 KB
testcase_06 AC 136 ms
10,220 KB
testcase_07 TLE -
testcase_08 AC 1,426 ms
10,340 KB
testcase_09 AC 1,783 ms
10,256 KB
testcase_10 AC 17 ms
8,060 KB
testcase_11 AC 17 ms
8,268 KB
testcase_12 AC 46 ms
8,012 KB
testcase_13 AC 96 ms
7,976 KB
testcase_14 AC 289 ms
8,568 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 221 ms
8,568 KB
testcase_18 WA -
testcase_19 AC 756 ms
8,596 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

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):
    #print(i, j)
    position_list[i][j] = v

    if i == j == N - 1:
        print("YES")
        exit()

    if i != 0 and position_list[i - 1][j] < v - L_list[i - 1][j] and v - L_list[i - 1][j] > 0:
        if i - 1 == Oy - 1 and j == Ox - 1:
            solve(i - 1, j, (v - L_list[i - 1][j]) * 2)
        else:
            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] and v - L_list[i + 1][j] > 0:
        if i + 1 == Oy - 1 and j == Ox - 1:
            solve(i + 1, j, (v - L_list[i + 1][j]) * 2)
        else:
            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]and v - L_list[i][j - 1] > 0:
        if i == Oy - 1 and j - 1 == Ox - 1:
            solve(i, j - 1, (v - L_list[i][j - 1]) * 2)
        else:
            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]and v - L_list[i][j + 1] > 0:
        if i == Oy - 1 and j + 1 == Ox - 1:
            solve(i, j + 1, (v - L_list[i][j + 1]) * 2)
        else:
            solve(i, j + 1, v - L_list[i][j + 1])

    return

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