結果
| 問題 |
No.2855 Move on Grid
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2024-09-02 00:20:32 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 890 bytes |
| コンパイル時間 | 306 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 19,100 KB |
| 最終ジャッジ日時 | 2024-09-02 00:20:56 |
| 合計ジャッジ時間 | 22,979 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 TLE * 1 -- * 29 |
ソースコード
import sys
input = sys.stdin.readline
from collections import deque
N,M,K=map(int,input().split())
MAP=[list(map(int,input().split())) for i in range(N)]
OK=0
NG=10**9+1
while NG>OK+1:
mid=(OK+NG)//2
DP=[[1<<63]*M for i in range(N)]
if MAP[0][0]<mid:
DP[0][0]=1
else:
DP[0][0]=0
Q=deque()
Q.append((0,0))
while Q:
x,y=Q.popleft()
for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
if 0<=z<N and 0<=w<M:
if MAP[z][w]<mid:
if DP[z][w]>DP[x][y]+1:
DP[z][w]=DP[x][y]+1
Q.append((z,w))
else:
if DP[z][w]>DP[x][y]:
DP[z][w]=DP[x][y]
Q.appendleft((z,w))
if DP[-1][-1]<=K:
OK=mid
else:
NG=mid
print(OK)
titia