結果

問題 No.2855 Move on Grid
ユーザー ryuusagiryuusagi
提出日時 2024-08-25 14:29:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 915 bytes
コンパイル時間 334 ms
コンパイル使用メモリ 82,380 KB
実行使用メモリ 119,800 KB
最終ジャッジ日時 2024-08-25 14:29:31
合計ジャッジ時間 15,763 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 381 ms
114,652 KB
testcase_11 AC 351 ms
114,836 KB
testcase_12 AC 376 ms
115,144 KB
testcase_13 AC 342 ms
114,840 KB
testcase_14 AC 378 ms
115,048 KB
testcase_15 AC 362 ms
115,140 KB
testcase_16 AC 358 ms
115,016 KB
testcase_17 AC 406 ms
114,940 KB
testcase_18 AC 346 ms
113,956 KB
testcase_19 AC 346 ms
115,032 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import*

n, m, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

ng = 10 ** 9 + 1
ok = 0
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    # begin mid が ok かどうか判定する為の前処理
    dp = [[-1] * m for _ in range(n)]
    dp[0][0] = int(a[0][0] < mid)
    q = deque([(0, 0)])
    while q:
        i, j = q.popleft()
        for x, y in [(i - 1, j), (i, j - 1), (i, j + 1), (i + 1, j)]:
            if 0 <= x < n and 0 <= y < m and dp[x][y] == -1:
                if a[x][y] < mid:
                    dp[x][y] = dp[i][j] + 1
                    q.append((x, y))
                else:
                    dp[x][y] = dp[i][j] + 1
                    q.appendleft((x, y))
    # end mid が ok かどうか判定する為の前処理
    if dp[-1][-1] <= k: # mid が ok の場合の条件
        ok = mid
    else:
        ng = mid
print(ok)
0