結果

問題 No.3299 K-th MMA String
ユーザー kidodesu
提出日時 2025-10-05 14:58:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 527 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 82,592 KB
実行使用メモリ 101,676 KB
最終ジャッジ日時 2025-10-05 14:58:25
合計ジャッジ時間 2,662 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
k -= 1
SU = [("", 0)]
S = []
while SU:
    s, f = SU.pop()
    if f == -1:
        S.pop()
        continue
    S.append(s)
    if len(S) == n+1 and f:
        if k:
            k -= 1
        else:
            exit(print("".join(S)))
    elif len(S) == n+1:
        pass
    else:
        SU.append(("", -1))
        SU.append(("M", f))
        SU.append(("", -1))
        if len(S) >= 2 and S[-2] + S[-1] == "MM":
            SU.append(("A", 1))
        else:
            SU.append(("A", f))
0