結果
問題 | No.2064 Smallest Sequence on Grid |
ユーザー | 👑 Kazun |
提出日時 | 2022-09-02 22:25:47 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,018 ms / 3,000 ms |
コード長 | 618 bytes |
コンパイル時間 | 556 ms |
コンパイル使用メモリ | 82,320 KB |
実行使用メモリ | 171,484 KB |
最終ジャッジ日時 | 2024-11-16 04:21:38 |
合計ジャッジ時間 | 17,390 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 |
ソースコード
def solve(): H,W=map(int,input().split()) S=[] for _ in range(H): S.append(list(map(ord,input()))) T=[chr(S[0][0])] Y={(0,0)} for _ in range(H+W-2): X=list(Y) Y=set() c=ord("z")+1 for i,j in X: if i+1<H and S[i+1][j]<c: c=S[i+1][j] if j+1<W and S[i][j+1]<c: c=S[i][j+1] for i,j in X: if i+1<H and S[i+1][j]==c: Y.add((i+1,j)) if j+1<W and S[i][j+1]==c: Y.add((i,j+1)) T.append(chr(c)) return "".join(T) print(solve())