結果

問題 No.2064 Smallest Sequence on Grid
ユーザー ニックネームニックネーム
提出日時 2022-09-02 22:00:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,946 ms / 3,000 ms
コード長 488 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 109,584 KB
最終ジャッジ日時 2023-08-10 04:01:09
合計ジャッジ時間 17,324 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,156 KB
testcase_01 AC 67 ms
71,284 KB
testcase_02 AC 66 ms
71,304 KB
testcase_03 AC 67 ms
71,156 KB
testcase_04 AC 68 ms
71,000 KB
testcase_05 AC 68 ms
71,292 KB
testcase_06 AC 69 ms
71,308 KB
testcase_07 AC 67 ms
71,288 KB
testcase_08 AC 69 ms
71,280 KB
testcase_09 AC 69 ms
71,276 KB
testcase_10 AC 69 ms
71,272 KB
testcase_11 AC 69 ms
71,032 KB
testcase_12 AC 69 ms
71,212 KB
testcase_13 AC 80 ms
76,460 KB
testcase_14 AC 78 ms
76,436 KB
testcase_15 AC 77 ms
76,008 KB
testcase_16 AC 80 ms
76,340 KB
testcase_17 AC 146 ms
85,308 KB
testcase_18 AC 146 ms
85,784 KB
testcase_19 AC 144 ms
85,840 KB
testcase_20 AC 1,445 ms
102,344 KB
testcase_21 AC 1,573 ms
103,216 KB
testcase_22 AC 1,036 ms
97,532 KB
testcase_23 AC 1,063 ms
98,032 KB
testcase_24 AC 1,057 ms
98,400 KB
testcase_25 AC 1,076 ms
97,940 KB
testcase_26 AC 1,946 ms
109,480 KB
testcase_27 AC 1,925 ms
109,544 KB
testcase_28 AC 149 ms
85,660 KB
testcase_29 AC 1,662 ms
109,584 KB
testcase_30 AC 152 ms
85,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h, w = map(int, input().split())
s = [input() for _ in range(h)]
ans = [s[0][0]]
tij = {(0, 0)}
m = s[0][0]
for _ in range(h+w-2):
    tij_new = set()
    m_new = "z"
    for i, j in tij:
        if s[i][j] == m and i < h-1:
            tij_new.add((i+1, j))
            m_new = min(m_new, s[i+1][j])
        if s[i][j] == m and j < w-1:
            tij_new.add((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