結果
問題 | No.2064 Smallest Sequence on Grid |
ユーザー |
![]() |
提出日時 | 2022-09-02 21:49:32 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 510 bytes |
コンパイル時間 | 360 ms |
コンパイル使用メモリ | 82,172 KB |
実行使用メモリ | 233,248 KB |
最終ジャッジ日時 | 2024-11-16 03:07:18 |
合計ジャッジ時間 | 24,924 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 TLE * 2 |
ソースコード
h, w = map(int, input().split()) s = [input() for _ in range(h)] ans = [s[0][0]] tij = {(0, 0, s[0][0])} m = s[0][0] for _ in range(h+w-2): tij_new = set() m_new = "z" for i, j, t in tij: if t == m and i < h-1: tij_new.add((i+1, j, s[i+1][j])) m_new = min(m_new, s[i+1][j]) if t == m and j < w-1: tij_new.add((i, j+1, s[i][j+1])) m_new = min(m_new, s[i][j+1]) tij = set(tij_new) m = m_new ans.append(m) print("".join(ans))