結果

問題 No.2064 Smallest Sequence on Grid
ユーザー titiatitia
提出日時 2022-09-09 07:23:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 626 bytes
コンパイル時間 621 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 17,432 KB
最終ジャッジ日時 2023-08-16 15:07:39
合計ジャッジ時間 10,006 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
12,244 KB
testcase_01 AC 15 ms
7,984 KB
testcase_02 AC 15 ms
7,936 KB
testcase_03 AC 14 ms
7,872 KB
testcase_04 AC 15 ms
7,860 KB
testcase_05 AC 14 ms
7,932 KB
testcase_06 AC 14 ms
7,980 KB
testcase_07 AC 15 ms
7,844 KB
testcase_08 AC 15 ms
7,920 KB
testcase_09 AC 16 ms
7,872 KB
testcase_10 AC 15 ms
7,792 KB
testcase_11 AC 16 ms
7,916 KB
testcase_12 AC 17 ms
7,920 KB
testcase_13 AC 17 ms
7,788 KB
testcase_14 AC 22 ms
7,924 KB
testcase_15 AC 20 ms
7,836 KB
testcase_16 AC 22 ms
8,360 KB
testcase_17 AC 51 ms
17,432 KB
testcase_18 AC 52 ms
17,324 KB
testcase_19 AC 51 ms
17,360 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

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