結果

問題 No.3135 AAABC
ユーザー moon17
提出日時 2025-05-02 22:37:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 701 ms / 2,000 ms
コード長 250 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 145,664 KB
最終ジャッジ日時 2025-05-02 22:37:24
合計ジャッジ時間 7,051 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
t=int(input())
q=[[]]
ans=set()
while q:
  p=q.pop()
  if len(p)==n:
    if set(p)=={*'ABC'}:
      ans.add(''.join(p))
    continue
  for nxt in'ABC':
    q+=p+[nxt],
ans=sorted(ans)
if t<=len(ans):
  print(ans[t-1])
else:
  print(-1)
0