結果
問題 | No.2064 Smallest Sequence on Grid |
ユーザー |
![]() |
提出日時 | 2022-09-02 21:45:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,319 ms / 3,000 ms |
コード長 | 771 bytes |
コンパイル時間 | 307 ms |
コンパイル使用メモリ | 82,468 KB |
実行使用メモリ | 251,484 KB |
最終ジャッジ日時 | 2024-11-16 02:57:51 |
合計ジャッジ時間 | 13,377 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 |
ソースコード
import sysinput = sys.stdin.readlineH,W=map(int,input().split())S=[list(map(lambda x:ord(x),input())) for _ in range(H)]INF=1<<60check = [[0]*W for _ in range(H)]ans = [S[0][0]]que = [(0,0)]check[0][0]=1while que:que2 = []smin = INFfor h,w in que:if h+1<H and check[h+1][w]==0:check[h+1][w]=1s = S[h+1][w]if s < smin:smin = sque2.append((s,h+1,w))if w+1<W and check[h][w+1]==0:check[h][w+1]=1s = S[h][w+1]if s < smin:smin = sque2.append((s,h,w+1))ans.append(smin)que = []for s,h,w in que2:if s==smin:que.append((h,w))print("".join(map(chr, ans[:-1])))