結果

問題 No.1111 コード進行
ユーザー onsen_manjuuuonsen_manjuuu
提出日時 2020-07-12 03:40:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 237 ms / 2,000 ms
コード長 928 bytes
コンパイル時間 2,083 ms
コンパイル使用メモリ 174,492 KB
実行使用メモリ 218,496 KB
最終ジャッジ日時 2024-04-21 21:25:45
合計ジャッジ時間 5,310 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 4 ms
6,016 KB
testcase_06 AC 7 ms
7,936 KB
testcase_07 AC 6 ms
7,296 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 5 ms
6,272 KB
testcase_10 AC 7 ms
9,856 KB
testcase_11 AC 4 ms
5,376 KB
testcase_12 AC 6 ms
7,936 KB
testcase_13 AC 5 ms
6,912 KB
testcase_14 AC 8 ms
10,496 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 7 ms
8,576 KB
testcase_17 AC 7 ms
10,112 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 4 ms
5,632 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 10 ms
12,416 KB
testcase_23 AC 4 ms
6,272 KB
testcase_24 AC 5 ms
7,424 KB
testcase_25 AC 10 ms
11,520 KB
testcase_26 AC 7 ms
7,680 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 87 ms
110,848 KB
testcase_29 AC 42 ms
48,000 KB
testcase_30 AC 63 ms
74,240 KB
testcase_31 AC 11 ms
15,360 KB
testcase_32 AC 66 ms
67,456 KB
testcase_33 AC 47 ms
44,544 KB
testcase_34 AC 63 ms
80,896 KB
testcase_35 AC 83 ms
103,168 KB
testcase_36 AC 116 ms
109,568 KB
testcase_37 AC 36 ms
29,696 KB
testcase_38 AC 26 ms
22,784 KB
testcase_39 AC 77 ms
73,472 KB
testcase_40 AC 102 ms
100,864 KB
testcase_41 AC 102 ms
123,008 KB
testcase_42 AC 59 ms
51,968 KB
testcase_43 AC 50 ms
45,568 KB
testcase_44 AC 26 ms
26,240 KB
testcase_45 AC 69 ms
75,904 KB
testcase_46 AC 10 ms
8,576 KB
testcase_47 AC 237 ms
218,496 KB
testcase_48 AC 10 ms
8,448 KB
testcase_49 AC 10 ms
8,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;

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 p, q, c; cin >> p >> q >> c; p--, q--;
        a[p].push_back({q, c});
    }

    vector<vector<vector<ll>>> dp(n, vector<vector<ll>>(300, vector<ll>(k + 1)));
    for(int i = 0; i < 300; i++)dp[0][i][0] = 1;

    for(int i = 0; i < n - 1; i++) {
        for(int j = 0; j < 300; j++) {

            for(auto p : a[j]) {
                for(int t = 0; t <= k; t++) {
                    if(p.second + t > k)break;
                    dp[i + 1][p.first][t + p.second] += dp[i][j][t];
                    dp[i + 1][p.first][t + p.second] %= mod;
                }
            }


        }
    }
    ll sum = 0;
    for(int i = 0; i < 300; i++)sum += dp[n - 1][i][k];
    cout << sum % mod << endl;

}
0