結果
問題 | No.3135 AAABC |
ユーザー |
|
提出日時 | 2025-05-02 21:32:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 685 ms / 2,000 ms |
コード長 | 536 bytes |
コンパイル時間 | 402 ms |
コンパイル使用メモリ | 82,600 KB |
実行使用メモリ | 144,320 KB |
最終ジャッジ日時 | 2025-05-02 21:32:28 |
合計ジャッジ時間 | 9,982 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 |
ソースコード
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))