結果

問題 No.2064 Smallest Sequence on Grid
ユーザー 👑 KazunKazun
提出日時 2022-09-02 22:04:01
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 669 bytes
コンパイル時間 122 ms
コンパイル使用メモリ 81,856 KB
実行使用メモリ 438,108 KB
最終ジャッジ日時 2024-04-27 21:38:43
合計ジャッジ時間 28,274 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
53,104 KB
testcase_01 AC 36 ms
52,704 KB
testcase_02 AC 37 ms
52,944 KB
testcase_03 AC 31 ms
52,832 KB
testcase_04 AC 34 ms
52,076 KB
testcase_05 AC 32 ms
52,528 KB
testcase_06 AC 32 ms
52,336 KB
testcase_07 AC 30 ms
52,180 KB
testcase_08 AC 32 ms
53,820 KB
testcase_09 AC 33 ms
53,020 KB
testcase_10 AC 33 ms
54,056 KB
testcase_11 AC 33 ms
53,152 KB
testcase_12 AC 33 ms
53,936 KB
testcase_13 AC 41 ms
61,868 KB
testcase_14 AC 47 ms
64,004 KB
testcase_15 AC 41 ms
62,492 KB
testcase_16 AC 44 ms
62,392 KB
testcase_17 AC 664 ms
425,400 KB
testcase_18 AC 654 ms
425,308 KB
testcase_19 AC 653 ms
425,348 KB
testcase_20 AC 2,390 ms
434,944 KB
testcase_21 AC 2,675 ms
435,816 KB
testcase_22 AC 1,790 ms
433,808 KB
testcase_23 AC 2,065 ms
434,288 KB
testcase_24 AC 2,067 ms
434,556 KB
testcase_25 AC 2,059 ms
434,848 KB
testcase_26 TLE -
testcase_27 TLE -
testcase_28 AC 653 ms
425,220 KB
testcase_29 AC 2,711 ms
379,640 KB
testcase_30 AC 616 ms
401,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

    T=[S[0][0]]
    Y={0}

    K=10000

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

        c=chr(ord("z")+1)
        for k in X:
            i,j=divmod(k,K)
            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 k in X:
            i,j=divmod(k,K)
            if i+1<H and S[i+1][j]==c:
                Y.add((i+1)*K+j)
            if j+1<W and S[i][j+1]==c:
                Y.add(i*K+(j+1))
        T.append(c)
    return "".join(T)

print(solve())
0