結果

問題 No.1111 コード進行
ユーザー minimamu21minimamu21
提出日時 2020-07-11 18:47:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 206 ms / 2,000 ms
コード長 756 bytes
コンパイル時間 1,614 ms
コンパイル使用メモリ 164,488 KB
実行使用メモリ 218,368 KB
最終ジャッジ日時 2024-04-21 10:03:59
合計ジャッジ時間 4,165 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 4 ms
6,940 KB
testcase_07 AC 4 ms
6,940 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 3 ms
6,944 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 4 ms
6,944 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 5 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 4 ms
7,224 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 4 ms
6,948 KB
testcase_23 AC 3 ms
6,944 KB
testcase_24 AC 3 ms
6,940 KB
testcase_25 AC 7 ms
7,296 KB
testcase_26 AC 4 ms
6,944 KB
testcase_27 AC 3 ms
6,940 KB
testcase_28 AC 6 ms
8,856 KB
testcase_29 AC 17 ms
17,280 KB
testcase_30 AC 16 ms
13,312 KB
testcase_31 AC 3 ms
6,944 KB
testcase_32 AC 28 ms
18,432 KB
testcase_33 AC 25 ms
12,544 KB
testcase_34 AC 5 ms
6,940 KB
testcase_35 AC 9 ms
9,600 KB
testcase_36 AC 153 ms
106,880 KB
testcase_37 AC 102 ms
88,832 KB
testcase_38 AC 52 ms
45,184 KB
testcase_39 AC 49 ms
26,752 KB
testcase_40 AC 115 ms
85,376 KB
testcase_41 AC 29 ms
26,368 KB
testcase_42 AC 108 ms
95,360 KB
testcase_43 AC 69 ms
54,272 KB
testcase_44 AC 31 ms
31,232 KB
testcase_45 AC 55 ms
49,408 KB
testcase_46 AC 17 ms
18,944 KB
testcase_47 AC 99 ms
19,712 KB
testcase_48 AC 206 ms
218,368 KB
testcase_49 AC 152 ms
162,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ll dp[305][305][305];
const int mod=1e9+7;

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    vector<int>p(m),q(m),c(m);
    rep(i,m)cin>>p[i]>>q[i]>>c[i];
    for(int i=1; i<=300; ++i){
        dp[0][i][0]=1;
    }
    for(int i=0; i<n-1; ++i){
        for(int j=0; j<=k; ++j){
            for(int l=0; l<m; ++l){
                if(j+c[l]<=k){
                    dp[i+1][q[l]][j+c[l]]+=dp[i][p[l]][j];
                    dp[i+1][q[l]][j+c[l]]%=mod;
                }
            }
        }
    }
    ll ans=0;
    for(int i=1; i<=300; ++i){
        ans+=dp[n-1][i][k];
        ans%=mod;
    }
    cout<<ans<<endl;
}
0