結果

問題 No.3135 AAABC
ユーザー 👑 p-adic
提出日時 2025-04-23 21:35:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 401 ms / 2,000 ms
コード長 484 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 82,640 KB
実行使用メモリ 130,784 KB
最終ジャッジ日時 2025-05-02 20:50:58
合計ジャッジ時間 4,701 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#1078586の亜種
from itertools import product

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

res=[]
def change(num):
    if num == 1:
        return "A"
    elif num == 2:
        return "B"
    else:
        return "C"
for i in product(*(range(1, 4) for i in range(N))):
    ele = []
    for j in range(N):
        ele += [change(i[j])]
    ele = "".join(ele)
    if "A" in ele and "B" in ele and "C" in ele:
        res.append(ele)

res=sorted(res)
try:
    print(res[S-1])
except:
    print(-1)
0