結果

問題 No.1111 コード進行
ユーザー 👑 NachiaNachia
提出日時 2020-10-24 19:04:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 330 ms / 2,000 ms
コード長 727 bytes
コンパイル時間 1,499 ms
コンパイル使用メモリ 166,336 KB
実行使用メモリ 214,972 KB
最終ジャッジ日時 2023-09-28 20:40:01
合計ジャッジ時間 6,698 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,100 KB
testcase_01 AC 4 ms
5,448 KB
testcase_02 AC 3 ms
4,736 KB
testcase_03 AC 3 ms
5,036 KB
testcase_04 AC 4 ms
4,740 KB
testcase_05 AC 5 ms
7,692 KB
testcase_06 AC 10 ms
8,912 KB
testcase_07 AC 13 ms
12,504 KB
testcase_08 AC 11 ms
11,748 KB
testcase_09 AC 6 ms
6,156 KB
testcase_10 AC 17 ms
16,024 KB
testcase_11 AC 10 ms
10,332 KB
testcase_12 AC 10 ms
8,988 KB
testcase_13 AC 8 ms
8,268 KB
testcase_14 AC 15 ms
11,800 KB
testcase_15 AC 14 ms
14,636 KB
testcase_16 AC 11 ms
9,696 KB
testcase_17 AC 17 ms
16,180 KB
testcase_18 AC 11 ms
12,076 KB
testcase_19 AC 4 ms
5,024 KB
testcase_20 AC 6 ms
6,192 KB
testcase_21 AC 12 ms
13,204 KB
testcase_22 AC 17 ms
15,320 KB
testcase_23 AC 11 ms
11,108 KB
testcase_24 AC 10 ms
9,628 KB
testcase_25 AC 14 ms
17,648 KB
testcase_26 AC 8 ms
15,604 KB
testcase_27 AC 4 ms
5,464 KB
testcase_28 AC 77 ms
129,916 KB
testcase_29 AC 45 ms
124,140 KB
testcase_30 AC 54 ms
87,440 KB
testcase_31 AC 12 ms
21,696 KB
testcase_32 AC 84 ms
162,064 KB
testcase_33 AC 43 ms
56,708 KB
testcase_34 AC 107 ms
110,092 KB
testcase_35 AC 86 ms
189,620 KB
testcase_36 AC 107 ms
132,408 KB
testcase_37 AC 42 ms
122,292 KB
testcase_38 AC 31 ms
87,352 KB
testcase_39 AC 69 ms
83,188 KB
testcase_40 AC 91 ms
138,444 KB
testcase_41 AC 90 ms
152,164 KB
testcase_42 AC 58 ms
130,292 KB
testcase_43 AC 50 ms
85,248 KB
testcase_44 AC 28 ms
77,112 KB
testcase_45 AC 60 ms
128,180 KB
testcase_46 AC 213 ms
214,960 KB
testcase_47 AC 330 ms
214,924 KB
testcase_48 AC 48 ms
214,972 KB
testcase_49 AC 49 ms
214,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

const ULL MOD = 1000000007;
int N, M, K;
ULL dp[300][300][301] = {};
ULL Ch[300][3];

int main() {
    cin >> N >> M >> K;
    rep(i, M) {
        rep(j, 3) cin >> Ch[i][j];
        Ch[i][0]--; Ch[i][1]--;
    }
    rep(i, 300) dp[0][i][0] = 1;

    rep(n, N - 1) rep(k, K + 1) {
        rep(m, M) {
            if (Ch[m][2] > k) continue;
            dp[n + 1][Ch[m][1]][k] += dp[n][Ch[m][0]][k - Ch[m][2]];
        }
        rep(s, 300) dp[n + 1][s][k] %= MOD;
    }

    ULL ans = 0;
    rep(i, 300) ans += dp[N - 1][i][K];
    ans %= MOD;
    cout << ans << endl;

    return 0;
}
0