Submission #22825025


Source Code Expand

#include <bits/stdc++.h>

#define rep(i, n) for (auto i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()

using namespace std;

using ll = long long int;

const int MOD_NUM = 1e9 + 7;

// 組み合わせ数(余り無し)
ll combination(ll n, ll r) {
    ll num = 1;
    for (auto i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int main() {
    // Input
    int A, B;
    ll K;
    cin >> A >> B >> K;

    // Process
    string ans;
    int a = A;
    int b = B;
    ll k = K - 1;
    rep(i, A + B) {
        ll ncb = combination(a + b - 1, b);
        if (k >= ncb) {
            ans += "b";
            k -= ncb;
            b--;
        } else {
            ans += "a";
            a--;
        }
    }

    // Output
    cout << ans << endl;

    return 0;
}

Submission Info

Submission Time
Task D - aab aba baa
User Koreander
Language C++ (GCC 9.2.1)
Score 400
Code Size 850 Byte
Status AC
Exec Time 8 ms
Memory 3564 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 28
Set Name Test Cases
Sample sample_00, sample_01
All big_00, big_01, big_02, big_03, big_04, bound_00, bound_01, bound_02, bound_03, sample_00, sample_01, small_00, small_01, test_00, test_01, test_02, test_03, test_04, test_05, test_06, test_07, test_08, test_09, test_10, test_11, test_12, test_13, test_14
Case Name Status Exec Time Memory
big_00 AC 8 ms 3460 KiB
big_01 AC 2 ms 3564 KiB
big_02 AC 3 ms 3504 KiB
big_03 AC 2 ms 3464 KiB
big_04 AC 2 ms 3448 KiB
bound_00 AC 3 ms 3448 KiB
bound_01 AC 2 ms 3448 KiB
bound_02 AC 2 ms 3548 KiB
bound_03 AC 3 ms 3444 KiB
sample_00 AC 3 ms 3504 KiB
sample_01 AC 3 ms 3480 KiB
small_00 AC 3 ms 3536 KiB
small_01 AC 3 ms 3480 KiB
test_00 AC 2 ms 3460 KiB
test_01 AC 3 ms 3464 KiB
test_02 AC 3 ms 3444 KiB
test_03 AC 2 ms 3436 KiB
test_04 AC 2 ms 3480 KiB
test_05 AC 2 ms 3444 KiB
test_06 AC 7 ms 3548 KiB
test_07 AC 2 ms 3444 KiB
test_08 AC 2 ms 3444 KiB
test_09 AC 2 ms 3536 KiB
test_10 AC 2 ms 3380 KiB
test_11 AC 3 ms 3528 KiB
test_12 AC 2 ms 3468 KiB
test_13 AC 2 ms 3380 KiB
test_14 AC 3 ms 3444 KiB