結果
| 問題 |
No.2064 Smallest Sequence on Grid
|
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2023-01-14 23:46:34 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 677 bytes |
| コンパイル時間 | 2,581 ms |
| コンパイル使用メモリ | 75,936 KB |
| 実行使用メモリ | 897,212 KB |
| 最終ジャッジ日時 | 2024-12-26 12:18:22 |
| 合計ジャッジ時間 | 63,920 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 MLE * 1 |
| other | AC * 10 WA * 1 TLE * 12 MLE * 6 |
ソースコード
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)
prev=queue
queue=[]
for h,w in prev[::-1]:
if w+1<W and S[h][w+1]==s:
if queue and (h,w+1)==queue[-1]:
continue
queue.append((h,w+1))
if h+1<H and S[h+1][w]==s:
if queue and (h+1,w)==queue[-1]:
continue
queue.append((h+1,w))
print("".join(ans_lst))
vwxyz