結果
問題 | No.2064 Smallest Sequence on Grid |
ユーザー | vwxyz |
提出日時 | 2023-01-14 23:32:48 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 557 bytes |
コンパイル時間 | 269 ms |
コンパイル使用メモリ | 87,284 KB |
実行使用メモリ | 849,128 KB |
最終ジャッジ日時 | 2023-08-27 04:09:43 |
合計ジャッジ時間 | 10,765 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
71,364 KB |
testcase_01 | AC | 71 ms
71,096 KB |
testcase_02 | AC | 73 ms
71,488 KB |
testcase_03 | AC | 72 ms
71,484 KB |
testcase_04 | AC | 71 ms
71,416 KB |
testcase_05 | AC | 74 ms
71,292 KB |
testcase_06 | AC | 74 ms
71,328 KB |
testcase_07 | AC | 73 ms
71,360 KB |
testcase_08 | AC | 73 ms
71,332 KB |
testcase_09 | AC | 72 ms
71,436 KB |
testcase_10 | AC | 74 ms
71,160 KB |
testcase_11 | AC | 1,773 ms
381,516 KB |
testcase_12 | MLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
ソースコード
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=[] for h,w in prev: if h+1<H and S[h+1][w]==s: queue.append((h+1,w)) if w+1<W and S[h][w+1]==s: if queue and (h,w+1)==queue[-1]: continue queue.append((h,w+1)) print(*ans_lst,sep="")