結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 4 ms
6,940 KB
testcase_07 AC 5 ms
6,944 KB
testcase_08 AC 5 ms
6,944 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 4 ms
6,940 KB
testcase_13 AC 3 ms
6,944 KB
testcase_14 AC 4 ms
6,944 KB
testcase_15 AC 3 ms
6,944 KB
testcase_16 AC 5 ms
6,940 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 4 ms
6,940 KB
testcase_23 AC 4 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 9 ms
7,296 KB
testcase_26 AC 5 ms
6,944 KB
testcase_27 AC 3 ms
6,940 KB
testcase_28 AC 6 ms
7,168 KB
testcase_29 AC 17 ms
17,280 KB
testcase_30 AC 17 ms
14,652 KB
testcase_31 AC 3 ms
6,940 KB
testcase_32 AC 32 ms
18,432 KB
testcase_33 AC 26 ms
14,028 KB
testcase_34 AC 6 ms
6,944 KB
testcase_35 AC 9 ms
9,728 KB
testcase_36 AC 151 ms
106,880 KB
testcase_37 AC 100 ms
88,832 KB
testcase_38 AC 56 ms
45,184 KB
testcase_39 AC 50 ms
26,496 KB
testcase_40 AC 116 ms
85,504 KB
testcase_41 AC 28 ms
26,240 KB
testcase_42 AC 116 ms
95,104 KB
testcase_43 AC 74 ms
54,400 KB
testcase_44 AC 35 ms
31,232 KB
testcase_45 AC 55 ms
49,408 KB
testcase_46 AC 38 ms
18,944 KB
testcase_47 AC 97 ms
19,584 KB
testcase_48 AC 234 ms
218,388 KB
testcase_49 AC 174 ms
162,432 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<=300; ++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