結果

問題 No.2064 Smallest Sequence on Grid
ユーザー vwxyzvwxyz
提出日時 2023-01-14 19:48:08
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 422 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 137,712 KB
最終ジャッジ日時 2023-08-27 00:55:28
合計ジャッジ時間 25,919 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,428 KB
testcase_01 AC 73 ms
71,336 KB
testcase_02 AC 74 ms
71,200 KB
testcase_03 AC 73 ms
71,312 KB
testcase_04 AC 73 ms
71,304 KB
testcase_05 AC 73 ms
71,192 KB
testcase_06 AC 72 ms
71,452 KB
testcase_07 AC 73 ms
71,456 KB
testcase_08 AC 74 ms
71,492 KB
testcase_09 AC 74 ms
71,376 KB
testcase_10 AC 74 ms
71,404 KB
testcase_11 AC 77 ms
75,304 KB
testcase_12 AC 76 ms
75,404 KB
testcase_13 AC 81 ms
76,084 KB
testcase_14 AC 86 ms
76,176 KB
testcase_15 AC 84 ms
76,176 KB
testcase_16 AC 83 ms
76,196 KB
testcase_17 AC 167 ms
87,096 KB
testcase_18 AC 166 ms
86,992 KB
testcase_19 AC 165 ms
87,140 KB
testcase_20 AC 2,202 ms
115,060 KB
testcase_21 AC 2,388 ms
120,100 KB
testcase_22 AC 1,562 ms
103,668 KB
testcase_23 AC 1,674 ms
113,628 KB
testcase_24 AC 1,684 ms
113,548 KB
testcase_25 AC 1,687 ms
113,388 KB
testcase_26 TLE -
testcase_27 TLE -
testcase_28 AC 176 ms
87,336 KB
testcase_29 AC 2,673 ms
123,272 KB
testcase_30 AC 189 ms
87,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline

H,W=map(int,readline().split())
S=[readline().rstrip() for h in range(H)]
ans_lst=[S[0][0]]
queue=[(0,0)]
for _ in range(H+W-2):
    s=min([S[h+1][w] for h,w in queue if h+1<H]+[S[h][w+1] for h,w in queue if w+1<W])
    ans_lst.append(s)
    queue=list({(h+1,w) for h,w in queue if h+1<H and S[h+1][w]==s}|{(h,w+1) for h,w in queue if w+1<W and S[h][w+1]==s})
print(*ans_lst,sep="")
0