結果

問題 No.3135 AAABC
ユーザー K2
提出日時 2025-05-02 22:01:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 395 bytes
コンパイル時間 543 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 107,964 KB
最終ジャッジ日時 2025-05-02 22:01:38
合計ジャッジ時間 3,348 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = int(input())

from collections import deque

ans = []
q = deque(["C", "B", "A"])

while q:
    s = q.pop()
    if len(s) == N:
        if s.count("A") != 0 and s.count("B") != 0 and s.count("C") != 0:
            ans.append(s)
    else:
        q.append(s + "C")
        q.append(s + "B")
        q.append(s + "A")

if S-1 < len(ans):
    print(ans[S-1])
else:
    print(-1)
0