結果

問題 No.3135 AAABC
コンテスト
ユーザー hato336
提出日時 2025-05-02 21:32:17
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 433 ms / 2,000 ms
コード長 536 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 217 ms
コンパイル使用メモリ 95,848 KB
実行使用メモリ 148,548 KB
最終ジャッジ日時 2026-07-10 10:49:07
合計ジャッジ時間 9,880 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)
#input = sys.stdin.readline
n = int(input())
s = int(input())
ans = []
a = 'ABC'
for i in itertools.product([0,1,2],repeat=n):
    cnt = [0,0,0]
    t = []
    for j in range(n):
        cnt[i[j]] += 1
        t.append(a[i[j]])
    if all(cnt[j] >= 1 for j in range(3)):
        ans.append(''.join(t))
ans.sort()
if s-1 < len(ans):
    print(ans[s-1])
else:
    exit(print(-1))
0