結果
問題 | No.2064 Smallest Sequence on Grid |
ユーザー |
![]() |
提出日時 | 2022-09-02 21:48:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,681 ms / 3,000 ms |
コード長 | 600 bytes |
コンパイル時間 | 377 ms |
コンパイル使用メモリ | 82,368 KB |
実行使用メモリ | 102,828 KB |
最終ジャッジ日時 | 2024-11-16 03:03:32 |
合計ジャッジ時間 | 15,658 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 |
ソースコード
H, W = map(int, input().split())S = [input() for _ in range(H)]dp = {(0, 0)}ans = S[0][0]for i in range(H+W-2):ndp = set()mins = 'zz'for h, w in dp:if h < H-1:nt = S[h+1][w]if mins == nt:ndp.add((h+1, w))elif mins > nt:ndp = {(h+1, w)}mins = ntif w < W-1:nt = S[h][w+1]if mins == nt:ndp.add((h, w+1))elif mins > nt:ndp = {(h, w+1)}mins = ntdp = ndpans += minsprint(ans)