結果
問題 |
No.2855 Move on Grid
|
ユーザー |
![]() |
提出日時 | 2024-09-03 19:40:17 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 825 bytes |
コンパイル時間 | 436 ms |
コンパイル使用メモリ | 82,104 KB |
実行使用メモリ | 760,504 KB |
最終ジャッジ日時 | 2024-09-03 19:40:25 |
合計ジャッジ時間 | 7,286 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 1 RE * 3 MLE * 2 -- * 34 |
ソースコード
from collections import deque N,M,K = map(int,input().split()) A = [list(map(int,input().split())) for i in range(N)] if N + M - 1 <= K: ans = 10 ** 9 exit() D = [(0,1),(0,-1),(-1,0),(1,0)] l = 1 r = 10 ** 9 + 1 while r - l > 1: m = (l + r) // 2 C = [[-1 for _ in range(N)] for _ in range(N)] if A[0][0] < m: C[0][0] = 1 else: A[0][0] = 0 dq = deque([(0,0)]) while len(dq): u,v = dq.popleft() c = C[u][v] for dx,dy in D: if 0 <= u + dx < N and 0 <= v + dy < M: uu,vv = u + dx,v + dy if C[uu][vv] != -1: continue cc = c if A[uu][vv] < m: cc += 1 C[uu][vv] = cc dq.append((uu,vv)) continue C[uu][vv] = cc dq.appendleft((uu,vv)) if C[-1][-1] <= K: l = m else: r = m print(l)