結果

問題 No.2064 Smallest Sequence on Grid
ユーザー titiatitia
提出日時 2022-09-09 07:23:32
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 595 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 82,472 KB
実行使用メモリ 133,472 KB
最終ジャッジ日時 2024-05-03 23:25:41
合計ジャッジ時間 26,529 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,184 KB
testcase_01 AC 39 ms
53,624 KB
testcase_02 AC 38 ms
52,512 KB
testcase_03 AC 38 ms
52,068 KB
testcase_04 AC 42 ms
52,972 KB
testcase_05 AC 39 ms
52,348 KB
testcase_06 AC 37 ms
53,296 KB
testcase_07 AC 40 ms
52,288 KB
testcase_08 AC 40 ms
52,228 KB
testcase_09 AC 38 ms
52,404 KB
testcase_10 AC 39 ms
53,120 KB
testcase_11 AC 46 ms
59,988 KB
testcase_12 AC 46 ms
60,760 KB
testcase_13 AC 50 ms
63,408 KB
testcase_14 AC 53 ms
64,384 KB
testcase_15 AC 51 ms
64,460 KB
testcase_16 AC 54 ms
64,556 KB
testcase_17 AC 118 ms
85,668 KB
testcase_18 AC 116 ms
85,644 KB
testcase_19 AC 119 ms
85,912 KB
testcase_20 AC 2,743 ms
120,800 KB
testcase_21 AC 2,995 ms
126,852 KB
testcase_22 AC 1,987 ms
106,268 KB
testcase_23 AC 1,753 ms
109,808 KB
testcase_24 AC 1,757 ms
109,740 KB
testcase_25 AC 1,747 ms
109,904 KB
testcase_26 TLE -
testcase_27 TLE -
testcase_28 AC 130 ms
85,824 KB
testcase_29 TLE -
testcase_30 AC 123 ms
85,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

H,W=map(int,input().split())
S=[input().strip() for i in range(H)]

Q=[(0,0)]

ANS=[S[0][0]]

while Q:
    D=dict()
    
    while Q:
        x,y=Q.pop()

        for z,w in [(x+1,y),(x,y+1)]:
            if 0<=z<H and 0<=w<W:
                k=S[z][w]
                if not(k in D):
                    D[k]=([(z,w)])
                else:
                    D[k].append((z,w))

    if list(D)==[]:
        break

    MIN=min(D)
    ANS.append(MIN)
    Q=[]

    for to in D[MIN]:
        Q.append(to)

    Q=list(set(Q))
        
print("".join(ANS))   
0