結果

問題 No.1111 コード進行
ユーザー auauaauaua
提出日時 2020-07-10 22:19:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 262 ms / 2,000 ms
コード長 1,060 bytes
コンパイル時間 1,908 ms
コンパイル使用メモリ 175,384 KB
実行使用メモリ 219,636 KB
最終ジャッジ日時 2023-08-01 18:19:05
合計ジャッジ時間 5,403 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 4 ms
6,748 KB
testcase_06 AC 7 ms
8,276 KB
testcase_07 AC 6 ms
7,524 KB
testcase_08 AC 4 ms
4,640 KB
testcase_09 AC 5 ms
6,680 KB
testcase_10 AC 8 ms
9,900 KB
testcase_11 AC 3 ms
4,760 KB
testcase_12 AC 7 ms
8,568 KB
testcase_13 AC 5 ms
6,952 KB
testcase_14 AC 10 ms
10,700 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 8 ms
8,852 KB
testcase_17 AC 8 ms
10,432 KB
testcase_18 AC 3 ms
4,572 KB
testcase_19 AC 3 ms
4,740 KB
testcase_20 AC 4 ms
6,060 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 10 ms
12,544 KB
testcase_23 AC 5 ms
6,420 KB
testcase_24 AC 5 ms
7,524 KB
testcase_25 AC 12 ms
11,872 KB
testcase_26 AC 7 ms
7,744 KB
testcase_27 AC 3 ms
4,944 KB
testcase_28 AC 82 ms
111,540 KB
testcase_29 AC 39 ms
48,140 KB
testcase_30 AC 62 ms
74,964 KB
testcase_31 AC 12 ms
15,716 KB
testcase_32 AC 69 ms
67,724 KB
testcase_33 AC 54 ms
45,068 KB
testcase_34 AC 60 ms
81,184 KB
testcase_35 AC 79 ms
103,756 KB
testcase_36 AC 185 ms
110,224 KB
testcase_37 AC 41 ms
29,768 KB
testcase_38 AC 33 ms
22,708 KB
testcase_39 AC 95 ms
74,172 KB
testcase_40 AC 139 ms
101,624 KB
testcase_41 AC 101 ms
123,744 KB
testcase_42 AC 74 ms
51,920 KB
testcase_43 AC 72 ms
45,812 KB
testcase_44 AC 29 ms
26,436 KB
testcase_45 AC 74 ms
76,168 KB
testcase_46 AC 10 ms
8,332 KB
testcase_47 AC 262 ms
219,636 KB
testcase_48 AC 10 ms
8,336 KB
testcase_49 AC 11 ms
8,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll n,m,k;cin>>n>>m>>k;
    vector<vector<vector<ll> > >dp(n+1,vector<vector<ll> >(301,vector<ll>(k+1)));
    rep(i,301){
        dp[0][i][0]=1;
    }
    vector<pair<pll,ll> >a(m);
    rep(i,m){
        ll p,q,c;cin>>p>>q>>c;
        a[i]=mp(mp(p,q),c);
    }
    rep(i,n-1){
        rep(j,k+1){
            rep(l,m){
                ll p=a[l].first.first;
                ll q=a[l].first.second;
                ll c=a[l].second;
                if(j+c>k)continue;
                dp[i+1][q][j+c]=(dp[i+1][q][j+c]+dp[i][p][j])%inf;
            }
        }
    }
    ll ans=0;
    rep(i,301){
        ans=(ans+dp[n-1][i][k])%inf;
    }
    cout<<ans<<endl;
}
0