結果

問題 No.2064 Smallest Sequence on Grid
コンテスト
ユーザー flippergo
提出日時 2026-09-13 10:14:06
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
MLE  
実行時間 -
コード長 1,015 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 565 ms
コンパイル使用メモリ 80,768 KB
実行使用メモリ 1,351,916 KB
最終ジャッジ日時 2026-09-13 10:14:20
合計ジャッジ時間 6,875 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 MLE * 2 -- * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

H,W = map(int,input().split())
S = [input().strip() for _ in range(H)]
ans = [S[0][0],[(0,0)]]
while True:
    T = ans[0]
    i,j = ans[1][0]
    if i+j==H+W-2:break
    ans[0] = T+"z"
    ans1 = []
    for i,j in ans[1]:
        if i==H-1:
            t = T+S[i][j+1]
            if t<ans[0]:
                ans[0] = t
                ans1 = [(i,j+1)]
            elif t==ans[0]:
                ans1.append((i,j+1))
        elif j==W-1:
            t = T+S[i+1][j]
            if t<ans[0]:
                ans[0] = t
                ans1 = [(i+1,j)]
            elif t==ans[0]:
                ans1.append((i+1,j))
        else:
            t = T+S[i][j+1]
            if t<ans[0]:
                ans[0]=t
                ans1 = [(i,j+1)]
            elif t==ans[0]:
                ans1.append((i,j+1))
            t = T+S[i+1][j]
            if t<ans[0]:
                ans[0]=t
                ans1 = [(i+1,j)]
            elif t==ans[0]:
                ans1.append((i+1,j))
    ans[1] = ans1
print(ans[0])
0