結果

問題 No.1111 コード進行
ユーザー kyoprounokyoprouno
提出日時 2020-07-10 22:13:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 379 ms / 2,000 ms
コード長 1,332 bytes
コンパイル時間 2,134 ms
コンパイル使用メモリ 180,856 KB
実行使用メモリ 359,512 KB
最終ジャッジ日時 2023-08-01 18:14:56
合計ジャッジ時間 8,647 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
8,848 KB
testcase_01 AC 6 ms
7,780 KB
testcase_02 AC 5 ms
6,400 KB
testcase_03 AC 4 ms
6,408 KB
testcase_04 AC 4 ms
6,532 KB
testcase_05 AC 5 ms
7,796 KB
testcase_06 AC 11 ms
13,664 KB
testcase_07 AC 16 ms
19,780 KB
testcase_08 AC 14 ms
18,484 KB
testcase_09 AC 7 ms
8,984 KB
testcase_10 AC 20 ms
25,548 KB
testcase_11 AC 11 ms
16,228 KB
testcase_12 AC 11 ms
13,736 KB
testcase_13 AC 9 ms
12,492 KB
testcase_14 AC 16 ms
18,284 KB
testcase_15 AC 17 ms
23,172 KB
testcase_16 AC 12 ms
14,864 KB
testcase_17 AC 19 ms
25,552 KB
testcase_18 AC 13 ms
18,416 KB
testcase_19 AC 4 ms
6,608 KB
testcase_20 AC 6 ms
8,848 KB
testcase_21 AC 15 ms
20,840 KB
testcase_22 AC 18 ms
24,352 KB
testcase_23 AC 13 ms
17,432 KB
testcase_24 AC 11 ms
14,860 KB
testcase_25 AC 22 ms
25,476 KB
testcase_26 AC 19 ms
22,148 KB
testcase_27 AC 5 ms
7,732 KB
testcase_28 AC 159 ms
216,228 KB
testcase_29 AC 158 ms
206,648 KB
testcase_30 AC 113 ms
142,756 KB
testcase_31 AC 25 ms
32,556 KB
testcase_32 AC 218 ms
270,536 KB
testcase_33 AC 87 ms
91,736 KB
testcase_34 AC 136 ms
181,884 KB
testcase_35 AC 233 ms
316,668 KB
testcase_36 AC 203 ms
218,464 KB
testcase_37 AC 161 ms
201,964 KB
testcase_38 AC 116 ms
145,068 KB
testcase_39 AC 131 ms
135,620 KB
testcase_40 AC 204 ms
230,340 KB
testcase_41 AC 192 ms
254,360 KB
testcase_42 AC 183 ms
216,032 KB
testcase_43 AC 123 ms
139,204 KB
testcase_44 AC 97 ms
125,008 KB
testcase_45 AC 165 ms
212,700 KB
testcase_46 AC 262 ms
359,512 KB
testcase_47 AC 379 ms
359,164 KB
testcase_48 AC 264 ms
359,408 KB
testcase_49 AC 259 ms
359,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll mod=1e9+7;

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