結果
問題 | No.2064 Smallest Sequence on Grid |
ユーザー | lloyz |
提出日時 | 2022-09-02 22:28:34 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 441 bytes |
コンパイル時間 | 195 ms |
コンパイル使用メモリ | 82,412 KB |
実行使用メモリ | 302,496 KB |
最終ジャッジ日時 | 2024-04-27 22:04:46 |
合計ジャッジ時間 | 6,410 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
52,904 KB |
testcase_01 | AC | 31 ms
52,544 KB |
testcase_02 | AC | 31 ms
53,964 KB |
testcase_03 | AC | 32 ms
53,012 KB |
testcase_04 | AC | 31 ms
52,824 KB |
testcase_05 | AC | 33 ms
53,348 KB |
testcase_06 | AC | 35 ms
53,496 KB |
testcase_07 | AC | 35 ms
53,292 KB |
testcase_08 | AC | 36 ms
53,860 KB |
testcase_09 | AC | 39 ms
54,060 KB |
testcase_10 | AC | 49 ms
62,700 KB |
testcase_11 | TLE | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
ソースコード
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))