結果

問題 No.250 atetubouのzetubou
ユーザー __t2kasa____t2kasa__
提出日時 2018-09-01 07:43:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,590 bytes
コンパイル時間 1,670 ms
コンパイル使用メモリ 164,396 KB
実行使用メモリ 38,768 KB
最終ジャッジ日時 2023-10-12 16:36:41
合計ジャッジ時間 3,059 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
38,480 KB
testcase_01 AC 17 ms
38,532 KB
testcase_02 AC 35 ms
38,480 KB
testcase_03 AC 37 ms
38,712 KB
testcase_04 WA -
testcase_05 AC 35 ms
38,536 KB
testcase_06 AC 30 ms
38,768 KB
testcase_07 AC 22 ms
38,488 KB
testcase_08 AC 34 ms
38,636 KB
testcase_09 AC 30 ms
38,568 KB
testcase_10 WA -
testcase_11 AC 26 ms
38,564 KB
testcase_12 AC 33 ms
38,568 KB
testcase_13 AC 26 ms
38,492 KB
testcase_14 AC 15 ms
38,556 KB
testcase_15 AC 36 ms
38,532 KB
testcase_16 AC 35 ms
38,564 KB
testcase_17 AC 36 ms
38,492 KB
testcase_18 AC 36 ms
38,488 KB
testcase_19 AC 36 ms
38,492 KB
testcase_20 AC 15 ms
38,504 KB
testcase_21 AC 15 ms
38,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// https://yukicoder.me/problems/no/302
// status:
// tag: [multi_choose]

#define SUBMIT
//#define DEBUG

#include <bits/stdc++.h>
using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_D = 1500;
const int MAX_K = 1500;

ui64 dp[(MAX_D + MAX_K - 1) + 1][MAX_K + 1];

// dp[i][j] i種類の品物を重複ありでj個選ぶ組み合わせの総数
// nC0 = 1
// 重複組合せではnHk = n+k-1Ck
// nCk = n-1Cr-1 + n-1Crの公式を用いる
// dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][r];

template <std::size_t N, std::size_t K, typename T>
void init_multi_choose(T dp[N][K], ui64 mod) {
    for (int i = 0; i < N; ++i) dp[i][0] = 1;

    for (int i = 0; i < N - 1; ++i) {
        for (int j = 1; j < K; ++j) {
            dp[i + 1][j] = (dp[i + 1][j] + dp[i][j - 1] + dp[i][j]) % mod;
        }
    }
}

template <std::size_t N, std::size_t K, typename T>
void init_multi_choose(T dp[N][K]) {
    for (int i = 0; i < N; ++i) dp[i][0] = 1;

    for (int i = 0; i < N - 1; ++i) {
        for (int j = 1; j < K; ++j) {
            dp[i + 1][j] = (dp[i + 1][j] + dp[i][j - 1] + dp[i][j]);
        }
    }
}

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(3
58 62 1000
12 34 56
987 65 1234
)");
#endif
    init_multi_choose<MAX_D + MAX_K, MAX_K + 1>(dp);

    ui64 Q;
    stream >> Q;
    ui64 D, K, T;
    for (int i = 0; i < Q; ++i) {
        stream >> D >> K >> T;

        auto n_runs = dp[D + K - 1][K];
        if (T < n_runs) cout << "ZETUBOU" << endl;
        else cout << "AC" << endl;
    }

    return 0;
}
0