結果
問題 |
No.2064 Smallest Sequence on Grid
|
ユーザー |
|
提出日時 | 2022-09-02 22:47:42 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 695 bytes |
コンパイル時間 | 399 ms |
コンパイル使用メモリ | 82,348 KB |
実行使用メモリ | 439,364 KB |
最終ジャッジ日時 | 2024-11-16 05:14:38 |
合計ジャッジ時間 | 30,583 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 TLE * 2 |
ソースコード
h, w = map(int, input().split()) S = [list(input()) for _ in range(h)] Directions = [(1, 0), (0, 1)] ans = S[0][0] C = set([0]) for _ in range(h + w - 2): minT = '' NC = set() 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.add(ni * w + nj) elif S[ni][nj] == minT: NC.add(ni * w + nj) elif S[ni][nj] < minT: minT = S[ni][nj] NC = set([ni * w + nj]) ans += minT C = NC print(ans)