結果
| 問題 | No.3135 AAABC |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-05-23 12:25:45 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 203 ms / 2,000 ms |
| コード長 | 894 bytes |
| 記録 | |
| コンパイル時間 | 3,802 ms |
| コンパイル使用メモリ | 289,716 KB |
| 実行使用メモリ | 31,628 KB |
| 最終ジャッジ日時 | 2025-05-23 12:25:52 |
| 合計ジャッジ時間 | 6,496 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
const ll MOD = 998244353;
int main() {
int n,s;
cin >> n >> s;
vector<char> abc={'A','B','C'};
vector<vector<char>> ans;
function<void(vector<char>)> dp=[&](vector<char> S){
if (S.size() == n) {
if (count(all(S), abc.at(0)) && count(all(S), abc.at(1)) && count(all(S), abc.at(2))) {
ans.push_back(S);
}
}
else {
for (char c : abc) {
S.push_back(c);
dp(S);
S.pop_back();
}
}
};
dp({});
sort(all(ans));
if (s > ans.size()) {
cout << -1 << endl;
return 0;
}
for (auto s : ans.at(s-1)){
cout << s;
}
cout << endl;
}