結果
問題 |
No.3135 AAABC
|
ユーザー |
![]() |
提出日時 | 2025-05-02 22:13:23 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 220 ms / 2,000 ms |
コード長 | 1,055 bytes |
コンパイル時間 | 5,632 ms |
コンパイル使用メモリ | 332,536 KB |
実行使用メモリ | 19,792 KB |
最終ジャッジ日時 | 2025-05-02 22:13:33 |
合計ジャッジ時間 | 7,710 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> using namespace std; using namespace chrono; #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif int main() { int64_t n, s; cin >> n >> s; s--; vector<string> ss; auto powi = [](int64_t a, int64_t n) -> int64_t { int64_t ret = 1; for (; n; n >>= 1) { if (n & 1) { ret *= a; } a *= a; } return ret; }; for (int64_t S = 0; S < powi(3, n); S++) { string t; bool a = false, b = false, c = false; for (int64_t i = 0, T = S; i < n; i++) { t += "ABC"[T % 3]; a |= T % 3 == 0; b |= T % 3 == 1; c |= T % 3 == 2; T /= 3; } if (a && b && c) { ss.push_back(t); } } ranges::sort(ss); if (s < ss.size()) { cout << ss[s] << endl; } else { cout << -1 << endl; } return 0; }