結果

問題 No.2064 Smallest Sequence on Grid
コンテスト
ユーザー Theta
提出日時 2022-12-12 18:40:17
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 630 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 57 ms
コンパイル使用メモリ 14,976 KB
実行使用メモリ 81,664 KB
最終ジャッジ日時 2026-09-19 19:02:47
合計ジャッジ時間 10,034 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def main():
    H, W = map(int, input().split())
    letters = [list(input()) for _ in range(H)]

    strings = ""
    current_h, current_w = 0, 0
    while current_h < (H-1) or current_w < (W-1):
        strings += letters[current_h][current_w]

        if current_h == H-1 or current_w == W-1:
            current_w = min(current_w+1, W-1)
            current_h = min(current_h+1, H-1)

        elif letters[current_h+1][current_w] < letters[current_h][current_w+1]:
            current_h += 1
        else:
            current_w += 1

    strings += letters[H-1][W-1]
    print(strings)


if __name__ == "__main__":
    main()
0