結果

問題 No.3135 AAABC
ユーザー urunea
提出日時 2025-04-21 09:31:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 266 ms / 2,000 ms
コード長 441 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 82,772 KB
実行使用メモリ 131,172 KB
最終ジャッジ日時 2025-05-02 20:50:42
合計ジャッジ時間 4,134 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

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])
    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