結果
| 問題 | No.2064 Smallest Sequence on Grid |
| コンテスト | |
| ユーザー |
ニックネーム
|
| 提出日時 | 2022-09-02 21:49:32 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 1,751 ms / 3,000 ms |
| コード長 | 510 bytes |
| 記録 | |
| コンパイル時間 | 212 ms |
| コンパイル使用メモリ | 84,992 KB |
| 実行使用メモリ | 214,400 KB |
| 最終ジャッジ日時 | 2026-05-11 07:03:34 |
| 合計ジャッジ時間 | 17,396 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 29 |
ソースコード
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))
ニックネーム