結果

問題 No.3135 AAABC
ユーザー akazuki8
提出日時 2025-05-02 22:10:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 769 ms / 2,000 ms
コード長 346 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 122,696 KB
最終ジャッジ日時 2025-05-02 22:11:01
合計ジャッジ時間 7,374 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
s=int(input())
a=[]
for i in range(3**n):
	b=[]
	A=False
	B=False
	C=False
	for j in range(n):
		x=i//pow(3,j)%3
		if x==0:
			b.append('A')
			A=True
		elif x==1:
			b.append('B')
			B=True
		else:
			b.append('C')
			C=True
	if A and B and C:
	    a.append(''.join(b))
a.sort()
if s<=len(a):
    print(a[s-1])
else:
    print(-1)
0