結果

問題 No.1111 コード進行
ユーザー merom686merom686
提出日時 2020-07-10 22:19:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 241 ms / 2,000 ms
コード長 1,091 bytes
コンパイル時間 702 ms
コンパイル使用メモリ 94,648 KB
実行使用メモリ 215,216 KB
最終ジャッジ日時 2024-04-19 17:31:17
合計ジャッジ時間 3,219 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 4 ms
10,168 KB
testcase_07 AC 5 ms
13,328 KB
testcase_08 AC 3 ms
12,288 KB
testcase_09 AC 3 ms
7,064 KB
testcase_10 AC 5 ms
16,340 KB
testcase_11 AC 3 ms
10,876 KB
testcase_12 AC 4 ms
11,064 KB
testcase_13 AC 2 ms
9,884 KB
testcase_14 AC 5 ms
12,784 KB
testcase_15 AC 5 ms
15,004 KB
testcase_16 AC 3 ms
10,176 KB
testcase_17 AC 4 ms
16,580 KB
testcase_18 AC 7 ms
12,032 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 3 ms
7,384 KB
testcase_21 AC 9 ms
13,340 KB
testcase_22 AC 6 ms
17,100 KB
testcase_23 AC 4 ms
12,624 KB
testcase_24 AC 4 ms
11,632 KB
testcase_25 AC 6 ms
17,056 KB
testcase_26 AC 5 ms
14,580 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 53 ms
129,876 KB
testcase_29 AC 39 ms
124,180 KB
testcase_30 AC 34 ms
86,852 KB
testcase_31 AC 7 ms
20,756 KB
testcase_32 AC 54 ms
162,200 KB
testcase_33 AC 25 ms
56,348 KB
testcase_34 AC 54 ms
109,372 KB
testcase_35 AC 60 ms
189,960 KB
testcase_36 AC 55 ms
131,408 KB
testcase_37 AC 35 ms
121,488 KB
testcase_38 AC 24 ms
88,136 KB
testcase_39 AC 35 ms
82,624 KB
testcase_40 AC 53 ms
138,296 KB
testcase_41 AC 55 ms
152,556 KB
testcase_42 AC 41 ms
130,748 KB
testcase_43 AC 29 ms
84,296 KB
testcase_44 AC 21 ms
76,808 KB
testcase_45 AC 41 ms
127,948 KB
testcase_46 AC 194 ms
215,216 KB
testcase_47 AC 241 ms
215,208 KB
testcase_48 AC 46 ms
215,216 KB
testcase_49 AC 46 ms
215,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

struct X {
    int p, q, c;
};

ll dp[300][300][301];//i番目まで見てlで終わって複雑さがc
X x[300];

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    n--;

    for (int j = 0; j < m; j++) {
        int p, q, c;
        cin >> p >> q >> c;
        p--; q--;
        x[j] = { p, q, c };
    }

    for (int l = 0; l < 300; l++) {
        dp[0][l][0] = 1;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            auto [p, q, c] = x[j];
            for (int h = c; h <= k; h++) {
                dp[i + 1][q][h] += dp[i][p][h - c];
            }
        }
        for (int l = 0; l < 300; l++) {
            for (int h = 0; h <= k; h++) {
                dp[i + 1][l][h] %= P;
            }
        }
    }

    ll r = 0;
    for (int l = 0; l < 300; l++) {
        r += dp[n][l][k];
    }
    cout << r % P << endl;

    return 0;
}
0