結果

問題 No.3135 AAABC
ユーザー sasa8uyauya
提出日時 2025-05-02 22:41:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 553 ms / 2,000 ms
コード長 257 bytes
コンパイル時間 501 ms
コンパイル使用メモリ 82,584 KB
実行使用メモリ 132,796 KB
最終ジャッジ日時 2025-05-02 22:41:58
合計ジャッジ時間 6,627 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
s=[]
t=[]

def f():
	if len(t)==n:
		if all(t.count(c)>0 for c in "ABC"):
			s.append("".join(t))
	else:
		for c in "ABC":
			t.append(c)
			f()
	if len(t)>0:
		t.pop()
	return

f()

m=int(input())-1
if m<len(s):
	print(s[m])
else:
	print(-1)
0