結果

問題 No.2064 Smallest Sequence on Grid
ユーザー vwxyzvwxyz
提出日時 2023-01-14 19:56:32
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 2,892 ms / 3,000 ms
コード長 423 bytes
コンパイル時間 1,892 ms
コンパイル使用メモリ 77,956 KB
実行使用メモリ 144,628 KB
最終ジャッジ日時 2023-08-27 01:04:21
合計ジャッジ時間 25,044 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
76,628 KB
testcase_01 AC 73 ms
76,532 KB
testcase_02 AC 71 ms
76,496 KB
testcase_03 AC 70 ms
76,632 KB
testcase_04 AC 70 ms
76,408 KB
testcase_05 AC 69 ms
76,556 KB
testcase_06 AC 68 ms
76,464 KB
testcase_07 AC 70 ms
76,316 KB
testcase_08 AC 70 ms
76,764 KB
testcase_09 AC 71 ms
76,428 KB
testcase_10 AC 68 ms
76,356 KB
testcase_11 AC 130 ms
78,280 KB
testcase_12 AC 74 ms
78,228 KB
testcase_13 AC 92 ms
79,232 KB
testcase_14 AC 82 ms
79,144 KB
testcase_15 AC 81 ms
79,164 KB
testcase_16 AC 83 ms
79,036 KB
testcase_17 AC 139 ms
89,288 KB
testcase_18 AC 134 ms
89,472 KB
testcase_19 AC 141 ms
89,148 KB
testcase_20 AC 2,092 ms
123,236 KB
testcase_21 AC 2,216 ms
126,156 KB
testcase_22 AC 1,475 ms
108,912 KB
testcase_23 AC 1,525 ms
113,852 KB
testcase_24 AC 1,529 ms
113,868 KB
testcase_25 AC 1,534 ms
114,652 KB
testcase_26 AC 2,892 ms
144,628 KB
testcase_27 AC 2,876 ms
144,576 KB
testcase_28 AC 134 ms
89,124 KB
testcase_29 AC 2,480 ms
128,372 KB
testcase_30 AC 147 ms
89,124 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("".join(ans_lst))
0