結果

問題 No.1111 コード進行
ユーザー erbowlerbowl
提出日時 2020-07-10 21:55:45
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 209 ms / 2,000 ms
コード長 1,004 bytes
コンパイル時間 2,490 ms
コンパイル使用メモリ 205,728 KB
実行使用メモリ 219,136 KB
最終ジャッジ日時 2024-04-19 16:59:28
合計ジャッジ時間 5,024 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 4 ms
6,784 KB
testcase_06 AC 5 ms
8,576 KB
testcase_07 AC 5 ms
7,552 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 4 ms
6,784 KB
testcase_10 AC 7 ms
10,112 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 5 ms
8,448 KB
testcase_13 AC 4 ms
7,168 KB
testcase_14 AC 8 ms
10,880 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 6 ms
9,088 KB
testcase_17 AC 6 ms
10,624 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 4 ms
6,144 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 9 ms
12,800 KB
testcase_23 AC 4 ms
6,528 KB
testcase_24 AC 5 ms
7,680 KB
testcase_25 AC 9 ms
12,032 KB
testcase_26 AC 5 ms
8,064 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 81 ms
111,488 KB
testcase_29 AC 38 ms
48,128 KB
testcase_30 AC 57 ms
74,880 KB
testcase_31 AC 11 ms
15,872 KB
testcase_32 AC 63 ms
67,584 KB
testcase_33 AC 43 ms
45,056 KB
testcase_34 AC 60 ms
81,280 KB
testcase_35 AC 78 ms
103,552 KB
testcase_36 AC 106 ms
109,952 KB
testcase_37 AC 32 ms
29,952 KB
testcase_38 AC 24 ms
22,784 KB
testcase_39 AC 72 ms
73,984 KB
testcase_40 AC 95 ms
101,376 KB
testcase_41 AC 92 ms
123,520 KB
testcase_42 AC 54 ms
52,096 KB
testcase_43 AC 43 ms
46,080 KB
testcase_44 AC 22 ms
26,496 KB
testcase_45 AC 64 ms
76,416 KB
testcase_46 AC 8 ms
8,448 KB
testcase_47 AC 209 ms
219,136 KB
testcase_48 AC 9 ms
8,448 KB
testcase_49 AC 9 ms
8,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
const ll MOD = 1e9+7;
int main() {
    ll n,m,k;
    std::cin >> n>>m>>k;
    vector<vector<pair<ll,ll>>> edges(300);
    for (int i = 0; i < m; i++) {
        ll p,q,c;
        std::cin >> p>>q>>c;
        p--;q--;
        edges[p].push_back({q,c});
    }
    vector<vector<vector<ll>>> dp(n+1,vector<vector<ll>>(300,vector<ll>(k+1,0)));
    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 e : edges[j]) {
                for (int ii = 0; ii <= k; ii++) {
                    if(ii-e.second>=0) dp[i+1][e.first][ii] += dp[i][j][ii-e.second];
                    dp[i+1][e.first][ii] %= MOD;
                }
            }
        }
    }
    
    ll ans = 0;
    for (int i = 0; i < 300; i++) {
        ans += dp[n-1][i][k];
        ans %= MOD;
    }
    
    std::cout << ans << std::endl;
}
0