結果

問題 No.1111 コード進行
ユーザー yuji9511yuji9511
提出日時 2020-07-10 22:11:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 1,338 bytes
コンパイル時間 1,895 ms
コンパイル使用メモリ 199,288 KB
実行使用メモリ 221,812 KB
最終ジャッジ日時 2023-08-01 18:10:51
合計ジャッジ時間 5,138 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 4 ms
5,136 KB
testcase_07 AC 4 ms
5,244 KB
testcase_08 AC 3 ms
5,124 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,876 KB
testcase_11 AC 3 ms
4,732 KB
testcase_12 AC 4 ms
5,088 KB
testcase_13 AC 3 ms
4,948 KB
testcase_14 AC 4 ms
5,164 KB
testcase_15 AC 3 ms
4,508 KB
testcase_16 AC 5 ms
5,724 KB
testcase_17 AC 3 ms
4,476 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,384 KB
testcase_21 AC 2 ms
4,504 KB
testcase_22 AC 4 ms
5,628 KB
testcase_23 AC 3 ms
5,088 KB
testcase_24 AC 3 ms
4,432 KB
testcase_25 AC 7 ms
7,184 KB
testcase_26 AC 4 ms
5,428 KB
testcase_27 AC 3 ms
4,380 KB
testcase_28 AC 7 ms
7,096 KB
testcase_29 AC 18 ms
17,196 KB
testcase_30 AC 17 ms
13,344 KB
testcase_31 AC 3 ms
4,584 KB
testcase_32 AC 29 ms
18,640 KB
testcase_33 AC 25 ms
12,308 KB
testcase_34 AC 6 ms
6,592 KB
testcase_35 AC 10 ms
9,564 KB
testcase_36 AC 140 ms
107,868 KB
testcase_37 AC 101 ms
89,364 KB
testcase_38 AC 52 ms
45,080 KB
testcase_39 AC 47 ms
26,484 KB
testcase_40 AC 111 ms
85,588 KB
testcase_41 AC 29 ms
26,484 KB
testcase_42 AC 114 ms
95,960 KB
testcase_43 AC 68 ms
54,448 KB
testcase_44 AC 33 ms
31,256 KB
testcase_45 AC 55 ms
49,528 KB
testcase_46 AC 19 ms
19,320 KB
testcase_47 AC 92 ms
19,800 KB
testcase_48 AC 226 ms
221,812 KB
testcase_49 AC 167 ms
163,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[310][310][310] = {};


void solve(){
    ll N,M,K;
    cin >> N >> M >> K;
    ll P[310], Q[310], C[310];
    ll dist[310][310] = {};
    rep(i,0,300){
        rep(j,0,300){
            if(i == j) dist[i][j] = 0;
            else dist[i][j] = INF;
        }
    }
    rep(i,0,M){
        cin >> P[i] >> Q[i] >> C[i];
        P[i]--; Q[i]--;
        dist[P[i]][Q[i]] = C[i];
    }

    
    rep(i,0,300){
        dp[0][i][0] = 1;
    }
    rep(n,0,N-1){
        rep(i,0,M){
            rep(k,0,K+1){
                if(k - C[i] >= 0){
                    dp[n+1][Q[i]][k] += dp[n][P[i]][k - C[i]];
                    dp[n+1][Q[i]][k] %= MOD;
                }
            }
        }
    }
    ll ans = 0;
    rep(i,0,300){
        ans += dp[N-1][i][K];
        ans %= MOD;
    }
    print(ans);

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
0