結果
問題 | No.2064 Smallest Sequence on Grid |
ユーザー |
![]() |
提出日時 | 2022-09-09 07:23:32 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,830 ms / 3,000 ms |
コード長 | 595 bytes |
コンパイル時間 | 147 ms |
コンパイル使用メモリ | 81,836 KB |
実行使用メモリ | 133,476 KB |
最終ジャッジ日時 | 2024-11-25 04:57:00 |
合計ジャッジ時間 | 22,620 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 |
ソースコード
import sysinput = sys.stdin.readlineH,W=map(int,input().split())S=[input().strip() for i in range(H)]Q=[(0,0)]ANS=[S[0][0]]while Q:D=dict()while Q:x,y=Q.pop()for z,w in [(x+1,y),(x,y+1)]:if 0<=z<H and 0<=w<W:k=S[z][w]if not(k in D):D[k]=([(z,w)])else:D[k].append((z,w))if list(D)==[]:breakMIN=min(D)ANS.append(MIN)Q=[]for to in D[MIN]:Q.append(to)Q=list(set(Q))print("".join(ANS))