結果

問題 No.2064 Smallest Sequence on Grid
ユーザー 👑 KazunKazun
提出日時 2022-09-02 22:01:55
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 598 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 82,736 KB
実行使用メモリ 442,740 KB
最終ジャッジ日時 2024-04-27 21:36:14
合計ジャッジ時間 24,670 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
59,128 KB
testcase_01 AC 38 ms
53,252 KB
testcase_02 AC 38 ms
52,024 KB
testcase_03 AC 37 ms
52,460 KB
testcase_04 AC 37 ms
53,004 KB
testcase_05 AC 39 ms
53,916 KB
testcase_06 AC 38 ms
52,024 KB
testcase_07 AC 37 ms
52,864 KB
testcase_08 AC 39 ms
53,844 KB
testcase_09 AC 38 ms
53,424 KB
testcase_10 AC 41 ms
54,648 KB
testcase_11 AC 40 ms
54,512 KB
testcase_12 AC 41 ms
53,804 KB
testcase_13 AC 48 ms
61,812 KB
testcase_14 AC 52 ms
64,360 KB
testcase_15 AC 51 ms
64,012 KB
testcase_16 AC 51 ms
63,572 KB
testcase_17 AC 737 ms
425,264 KB
testcase_18 AC 732 ms
425,456 KB
testcase_19 AC 732 ms
425,796 KB
testcase_20 AC 2,801 ms
441,152 KB
testcase_21 TLE -
testcase_22 AC 2,030 ms
439,104 KB
testcase_23 AC 2,245 ms
439,900 KB
testcase_24 AC 2,236 ms
439,676 KB
testcase_25 AC 2,276 ms
439,624 KB
testcase_26 TLE -
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    H,W=map(int,input().split())
    S=[]
    for _ in range(H):
        S.append(list(input()))

    T=[S[0][0]]
    Y={(0,0)}

    for _ in range(H+W-2):
        X=Y
        Y=set()

        c=chr(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(c)
    return "".join(T)

print(solve())
0