結果

問題 No.1111 コード進行
ユーザー betrue12betrue12
提出日時 2020-07-10 21:39:32
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 768 bytes
コンパイル時間 2,096 ms
コンパイル使用メモリ 201,464 KB
実行使用メモリ 215,228 KB
最終ジャッジ日時 2024-04-19 16:20:14
合計ジャッジ時間 4,752 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,948 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 4 ms
6,940 KB
testcase_07 AC 4 ms
6,940 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 4 ms
6,944 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 5 ms
6,940 KB
testcase_13 AC 4 ms
6,944 KB
testcase_14 AC 4 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 5 ms
6,944 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 5 ms
6,940 KB
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 3 ms
6,944 KB
testcase_25 AC 7 ms
7,424 KB
testcase_26 AC 4 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 24 ms
7,168 KB
testcase_29 AC 23 ms
17,280 KB
testcase_30 AC 27 ms
13,312 KB
testcase_31 AC 4 ms
6,940 KB
testcase_32 AC 36 ms
18,560 KB
testcase_33 AC 27 ms
12,672 KB
testcase_34 AC 19 ms
6,944 KB
testcase_35 AC 26 ms
9,728 KB
testcase_36 AC 141 ms
106,112 KB
testcase_37 AC 93 ms
88,320 KB
testcase_38 AC 50 ms
45,056 KB
testcase_39 AC 53 ms
26,368 KB
testcase_40 AC 111 ms
85,120 KB
testcase_41 AC 47 ms
26,368 KB
testcase_42 AC 106 ms
94,336 KB
testcase_43 AC 68 ms
53,504 KB
testcase_44 AC 34 ms
31,232 KB
testcase_45 AC 62 ms
49,408 KB
testcase_46 AC 17 ms
18,688 KB
testcase_47 AC 119 ms
19,456 KB
testcase_48 AC 203 ms
215,228 KB
testcase_49 AC 147 ms
161,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int main(){
    int N, M, K;
    cin >> N >> M >> K;
    vector<vector<pair<int, int>>> A(300);
    for(int i=0; i<M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        A[a-1].emplace_back(b-1, c);
    }

    static int64_t dp[300][300][301];
    for(int j=0; j<300; j++) dp[0][j][0] = 1;
    for(int i=0; i<N-1; i++) for(int j=0; j<300; j++) for(int k=0; k<=K; k++) for(auto& [b, c] : A[j]){
        if(k+c <= K) add(dp[i+1][b][k+c], dp[i][j][k]);
    }
    int64_t ans = 0;
    for(int j=0; j<300; j++) add(ans, dp[N-1][j][K]);
    cout << ans << endl;
    return 0;
}
0