結果

問題 No.3135 AAABC
ユーザー firiexp
提出日時 2025-07-21 18:18:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 925 bytes
コンパイル時間 1,061 ms
コンパイル使用メモリ 101,296 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-07-21 18:18:48
合計ジャッジ時間 3,003 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <limits>
#include <array>

static const int MOD = 998244353;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

void f(string &a, int &c, int n, int used){
    if(c <= 0) return;
    if(a.size() == n){
        if(used != 7) return;
        c--;
        if(c == 0){
            cout << a << endl;
        }
        return;
    }
    for (int i = 0; i < 3; ++i) {
        a += char('A' + i);
        f(a, c, n, used | (1 << i));
        if(c <= 0) return;
        a.pop_back();
    }
}

int main() {
    int n, c;
    cin >> n >> c;
    string a;
    f(a, c, n, 0);
    if(c > 0){
        cout << -1 << endl;
    }
    return 0;
}
0