結果
| 問題 |
No.2064 Smallest Sequence on Grid
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-02 22:28:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 441 bytes |
| コンパイル時間 | 433 ms |
| コンパイル使用メモリ | 82,232 KB |
| 実行使用メモリ | 693,892 KB |
| 最終ジャッジ日時 | 2024-11-16 04:28:33 |
| 合計ジャッジ時間 | 80,537 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 10 TLE * 6 MLE * 13 |
ソースコード
from heapq import heapify, heappop, heappush
h, w = map(int, input().split())
S = [list(input()) for _ in range(h)]
Directions = [(1, 0), (0, 1)]
H = [(S[0][0], 0, 0)]
heapify(H)
while H:
res, ci, cj = heappop(H)
if ci == h - 1 and cj == w - 1:
print(res)
break
for di, dj in Directions:
ni = ci + di
nj = cj + dj
if ni < h and nj < w:
heappush(H, (res + S[ni][nj], ni, nj))