結果

問題 No.2064 Smallest Sequence on Grid
ユーザー ニックネームニックネーム
提出日時 2022-09-02 21:49:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,545 ms / 3,000 ms
コード長 510 bytes
コンパイル時間 125 ms
コンパイル使用メモリ 82,524 KB
実行使用メモリ 233,436 KB
最終ジャッジ日時 2024-04-27 21:20:35
合計ジャッジ時間 20,510 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,192 KB
testcase_01 AC 32 ms
52,404 KB
testcase_02 AC 32 ms
52,280 KB
testcase_03 AC 31 ms
52,696 KB
testcase_04 AC 30 ms
53,148 KB
testcase_05 AC 32 ms
52,520 KB
testcase_06 AC 33 ms
53,284 KB
testcase_07 AC 33 ms
52,148 KB
testcase_08 AC 33 ms
53,200 KB
testcase_09 AC 33 ms
53,108 KB
testcase_10 AC 35 ms
58,648 KB
testcase_11 AC 36 ms
59,304 KB
testcase_12 AC 36 ms
59,076 KB
testcase_13 AC 42 ms
63,160 KB
testcase_14 AC 44 ms
64,664 KB
testcase_15 AC 44 ms
64,512 KB
testcase_16 AC 46 ms
64,956 KB
testcase_17 AC 124 ms
85,164 KB
testcase_18 AC 103 ms
84,704 KB
testcase_19 AC 110 ms
85,072 KB
testcase_20 AC 1,979 ms
178,952 KB
testcase_21 AC 2,098 ms
188,988 KB
testcase_22 AC 1,525 ms
146,476 KB
testcase_23 AC 1,365 ms
159,588 KB
testcase_24 AC 1,344 ms
159,288 KB
testcase_25 AC 1,334 ms
159,724 KB
testcase_26 AC 2,545 ms
233,436 KB
testcase_27 AC 2,513 ms
233,316 KB
testcase_28 AC 106 ms
84,828 KB
testcase_29 AC 2,232 ms
228,932 KB
testcase_30 AC 113 ms
85,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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))
0