結果

問題 No.2064 Smallest Sequence on Grid
ユーザー vwxyzvwxyz
提出日時 2023-01-14 23:56:56
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 436 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 143,792 KB
最終ジャッジ日時 2023-08-27 04:29:57
合計ジャッジ時間 24,730 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,212 KB
testcase_01 AC 70 ms
71,284 KB
testcase_02 AC 71 ms
71,364 KB
testcase_03 AC 72 ms
71,140 KB
testcase_04 AC 71 ms
71,148 KB
testcase_05 AC 72 ms
71,204 KB
testcase_06 AC 70 ms
71,008 KB
testcase_07 AC 70 ms
71,312 KB
testcase_08 AC 70 ms
71,280 KB
testcase_09 AC 71 ms
71,368 KB
testcase_10 AC 71 ms
71,204 KB
testcase_11 AC 95 ms
75,084 KB
testcase_12 AC 74 ms
75,280 KB
testcase_13 AC 81 ms
75,892 KB
testcase_14 AC 87 ms
76,088 KB
testcase_15 AC 85 ms
76,152 KB
testcase_16 AC 87 ms
76,136 KB
testcase_17 AC 164 ms
86,936 KB
testcase_18 AC 154 ms
87,032 KB
testcase_19 AC 158 ms
87,204 KB
testcase_20 AC 2,167 ms
118,480 KB
testcase_21 AC 2,323 ms
122,648 KB
testcase_22 AC 1,510 ms
105,356 KB
testcase_23 AC 1,640 ms
115,444 KB
testcase_24 AC 1,637 ms
116,204 KB
testcase_25 AC 1,646 ms
115,736 KB
testcase_26 TLE -
testcase_27 TLE -
testcase_28 AC 164 ms
87,164 KB
testcase_29 AC 2,640 ms
127,748 KB
testcase_30 AC 181 ms
87,020 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)
    prev=queue
    queue=list({(h+1,w) for h,w in prev if h+1<H and S[h+1][w]==s}|{(h,w+1) for h,w in prev if w+1<W and S[h][w+1]==s})
print("".join(ans_lst))
0