結果
問題 |
No.2064 Smallest Sequence on Grid
|
ユーザー |
|
提出日時 | 2022-09-02 22:45:54 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 725 bytes |
コンパイル時間 | 1,046 ms |
コンパイル使用メモリ | 82,320 KB |
実行使用メモリ | 856,184 KB |
最終ジャッジ日時 | 2024-11-16 05:08:31 |
合計ジャッジ時間 | 72,892 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 MLE * 1 |
other | AC * 7 TLE * 13 MLE * 9 |
ソースコード
from copy import deepcopy h, w = map(int, input().split()) S = [list(input()) for _ in range(h)] Directions = [(1, 0), (0, 1)] ans = S[0][0] C = [0] for _ in range(h + w - 2): minT = '' NC = [] for c in C: ci, cj = divmod(c, w) for di, dj in Directions: ni = ci + di nj = cj + dj if ni < h and nj < w: if minT == '': minT = S[ni][nj] NC.append(ni * w + nj) elif S[ni][nj] == minT: NC.append(ni * w + nj) elif S[ni][nj] < minT: minT = S[ni][nj] NC = [ni * w + nj] ans += minT C = deepcopy(NC) print(ans)