提出 #22828381


ソースコード 拡げる

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const ll modn = 1000000007;

vector<vector<ll> > comb(int n) {
    vector<vector<ll> > v(n + 1, vector<ll>(n + 1, 0));
    for (int i = 0; i < v.size(); i++) {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (int j = 1; j < v.size(); j++) {
        for (int k = 1; k < j; k++) {
            v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
        }
    }
    return v;
}

int main()
{ 
    int A, B, L;
    ll K;
    cin >> A >> B >> K;
    L = A + B;
    vector<vector<ll> > c = comb(60);

    int g, copt = L;
    while (B > 0) {
        for (g = B; g <= L; g++) {
            if (K <= c[g][B]) {
                for (int i = 0; i < L - g; i++) {
                    cout << "a";
                    copt--;
                }
                cout << "b";
                copt--;

                K = K - c[g - 1][B];
                L = g - 1;
                A = A - L - g;
                B = B - 1;
                break;
            }
        }
    }
    for (int i = 0; i < copt; i++) {
        cout << "a";
    }
    cout << endl;

    return 0;
}

提出情報

提出日時
問題 D - aab aba baa
ユーザ ameolp
言語 C++ (GCC 9.2.1)
得点 400
コード長 1625 Byte
結果 AC
実行時間 9 ms
メモリ 3632 KiB

コンパイルエラー

./Main.cpp: In function ‘std::vector<std::vector<long long int> > comb(int)’:
./Main.cpp:31:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::vector<long long int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   31 |     for (int i = 0; i < v.size(); i++) {
      |                     ~~^~~~~~~~~~
./Main.cpp:35:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::vector<long long int> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   35 |     for (int j = 1; j < v.size(); j++) {
      |                     ~~^~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 2
AC × 28
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
big_00 AC 9 ms 3616 KiB
big_01 AC 3 ms 3444 KiB
big_02 AC 2 ms 3416 KiB
big_03 AC 3 ms 3632 KiB
big_04 AC 3 ms 3508 KiB
bound_00 AC 2 ms 3476 KiB
bound_01 AC 3 ms 3508 KiB
bound_02 AC 5 ms 3548 KiB
bound_03 AC 2 ms 3476 KiB
sample_00 AC 2 ms 3504 KiB
sample_01 AC 2 ms 3508 KiB
small_00 AC 3 ms 3612 KiB
small_01 AC 2 ms 3616 KiB
test_00 AC 2 ms 3416 KiB
test_01 AC 2 ms 3476 KiB
test_02 AC 2 ms 3616 KiB
test_03 AC 2 ms 3604 KiB
test_04 AC 5 ms 3560 KiB
test_05 AC 3 ms 3444 KiB
test_06 AC 2 ms 3504 KiB
test_07 AC 3 ms 3504 KiB
test_08 AC 3 ms 3600 KiB
test_09 AC 2 ms 3488 KiB
test_10 AC 3 ms 3600 KiB
test_11 AC 3 ms 3604 KiB
test_12 AC 2 ms 3424 KiB
test_13 AC 3 ms 3428 KiB
test_14 AC 3 ms 3604 KiB