結果
問題 | No.2064 Smallest Sequence on Grid |
ユーザー |
![]() |
提出日時 | 2023-01-14 19:56:19 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 423 bytes |
コンパイル時間 | 274 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 38,388 KB |
最終ジャッジ日時 | 2024-12-26 05:26:10 |
合計ジャッジ時間 | 39,615 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 TLE * 9 |
ソースコード
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))