結果

問題 No.1111 コード進行
ユーザー kyoprounokyoprouno
提出日時 2020-07-10 22:13:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 356 ms / 2,000 ms
コード長 1,332 bytes
コンパイル時間 2,207 ms
コンパイル使用メモリ 180,436 KB
実行使用メモリ 359,680 KB
最終ジャッジ日時 2024-04-19 17:26:58
合計ジャッジ時間 7,249 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
9,088 KB
testcase_01 AC 4 ms
7,936 KB
testcase_02 AC 4 ms
6,944 KB
testcase_03 AC 4 ms
7,040 KB
testcase_04 AC 4 ms
6,940 KB
testcase_05 AC 5 ms
8,064 KB
testcase_06 AC 10 ms
14,080 KB
testcase_07 AC 15 ms
19,840 KB
testcase_08 AC 13 ms
18,560 KB
testcase_09 AC 6 ms
9,344 KB
testcase_10 AC 18 ms
25,728 KB
testcase_11 AC 11 ms
16,256 KB
testcase_12 AC 10 ms
13,824 KB
testcase_13 AC 9 ms
12,672 KB
testcase_14 AC 15 ms
18,560 KB
testcase_15 AC 16 ms
23,296 KB
testcase_16 AC 11 ms
15,104 KB
testcase_17 AC 18 ms
25,728 KB
testcase_18 AC 13 ms
18,560 KB
testcase_19 AC 4 ms
6,940 KB
testcase_20 AC 6 ms
9,088 KB
testcase_21 AC 14 ms
21,120 KB
testcase_22 AC 17 ms
24,576 KB
testcase_23 AC 12 ms
17,664 KB
testcase_24 AC 10 ms
15,232 KB
testcase_25 AC 20 ms
25,728 KB
testcase_26 AC 17 ms
22,144 KB
testcase_27 AC 5 ms
7,936 KB
testcase_28 AC 152 ms
216,448 KB
testcase_29 AC 147 ms
206,848 KB
testcase_30 AC 110 ms
142,848 KB
testcase_31 AC 23 ms
32,768 KB
testcase_32 AC 203 ms
270,720 KB
testcase_33 AC 84 ms
92,032 KB
testcase_34 AC 128 ms
181,888 KB
testcase_35 AC 222 ms
316,928 KB
testcase_36 AC 197 ms
218,752 KB
testcase_37 AC 161 ms
202,112 KB
testcase_38 AC 115 ms
145,408 KB
testcase_39 AC 124 ms
135,936 KB
testcase_40 AC 194 ms
230,528 KB
testcase_41 AC 185 ms
254,336 KB
testcase_42 AC 177 ms
216,448 KB
testcase_43 AC 125 ms
139,520 KB
testcase_44 AC 98 ms
125,312 KB
testcase_45 AC 164 ms
212,992 KB
testcase_46 AC 272 ms
359,552 KB
testcase_47 AC 356 ms
359,680 KB
testcase_48 AC 260 ms
359,680 KB
testcase_49 AC 255 ms
359,680 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