結果

問題 No.1111 コード進行
ユーザー momoyuumomoyuu
提出日時 2022-08-18 17:31:34
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 239 ms / 2,000 ms
コード長 1,185 bytes
コンパイル時間 3,912 ms
コンパイル使用メモリ 281,720 KB
実行使用メモリ 113,024 KB
最終ジャッジ日時 2024-04-16 01:36:06
合計ジャッジ時間 6,691 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 5 ms
6,016 KB
testcase_07 AC 5 ms
5,504 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 6 ms
6,784 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 6 ms
5,888 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 8 ms
7,296 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 5 ms
6,272 KB
testcase_17 AC 5 ms
7,040 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 6 ms
8,064 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 4 ms
5,504 KB
testcase_25 AC 8 ms
7,680 KB
testcase_26 AC 6 ms
5,760 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 49 ms
58,752 KB
testcase_29 AC 28 ms
27,136 KB
testcase_30 AC 42 ms
39,808 KB
testcase_31 AC 7 ms
9,600 KB
testcase_32 AC 55 ms
36,736 KB
testcase_33 AC 46 ms
24,704 KB
testcase_34 AC 35 ms
42,880 KB
testcase_35 AC 48 ms
54,912 KB
testcase_36 AC 108 ms
57,728 KB
testcase_37 AC 35 ms
18,048 KB
testcase_38 AC 27 ms
13,824 KB
testcase_39 AC 74 ms
39,552 KB
testcase_40 AC 86 ms
53,504 KB
testcase_41 AC 60 ms
64,896 KB
testcase_42 AC 54 ms
29,056 KB
testcase_43 AC 52 ms
25,344 KB
testcase_44 AC 20 ms
15,104 KB
testcase_45 AC 49 ms
40,448 KB
testcase_46 AC 10 ms
8,576 KB
testcase_47 AC 239 ms
113,024 KB
testcase_48 AC 11 ms
8,576 KB
testcase_49 AC 11 ms
8,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template<class t> using vc = vector<t>;
template<class t> using vvc = vc<vc<t>>;
using pi = pair<int,int>;
using vi = vc<int>;
using vvi = vvc<int>;

#define rep(i,a,b) for (int i = a; i < b; i++)
#define irep(i,a,b) for (int i = a; i > b; i--)
#define print(n) cout << n << endl
#define rup(a,b) (a+b-1)/b
#define input(A,N) rep(i,0,N) cin>>A[i];


int main(){
    cout << fixed << setprecision(15);
    
    int N,M,K;
    ll mod = ll(pow(10,9))+7;
    cin >> N >> M >> K;
    int P[M],Q[M],C[M];
    rep(i,0,M)  cin>>P[i]>>Q[i]>>C[i];
    vc<vvi> dp(N+1,vvi(300,vi(K+1,0)));
    int now = 0;
    rep(i,0,M){
        if (C[i]>K) continue;
        dp[1][Q[i]-1][C[i]]++;
    }
    rep(i,1,N){
        rep(j,0,M){
            rep(k,0,K+1){
                if(k+C[j]>K) break;
                dp[i+1][Q[j]-1][k+C[j]] += dp[i][P[j]-1][k];
                dp[i+1][Q[j]-1][k+C[j]] %= mod;
            }
        }
    }
    ll ans = 0;
    rep(i,0,300){
        ans += dp[N-1][i][K];
        ans %= mod;
    }
    print(ans);
    //system("pause");
    return 0;
}
0