結果
| 問題 | No.2064 Smallest Sequence on Grid |
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2023-01-14 23:57:34 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 1,570 ms / 3,000 ms |
| コード長 | 466 bytes |
| 記録 | |
| コンパイル時間 | 329 ms |
| コンパイル使用メモリ | 84,864 KB |
| 実行使用メモリ | 117,504 KB |
| 最終ジャッジ日時 | 2026-06-01 09:46:26 |
| 合計ジャッジ時間 | 13,862 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 29 |
ソースコード
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="{"
for h,w in queue:
if h+1<H:
s=min(s,S[h+1][w])
if w+1<W:
s=min(s,S[h][w+1])
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))
vwxyz