結果

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

ソースコード

diff #

from itertools import product


def make(n: int):
    res = []
    for ps in product(range(3), repeat=n):
        if not all(x in ps for x in [0, 1, 2]):
            continue

        res.append(ps[:])

    return res


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

cands = make(N)
if S > len(cands):
    print(-1)
    exit()

d = {0: 'A', 1: 'B', 2: 'C'}
ans = ''.join(d[x] for x in cands[S-1])
print(ans)
0