結果

問題 No.1111 コード進行
ユーザー minimamu21
提出日時 2020-07-11 18:45:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 244 ms / 2,000 ms
コード長 758 bytes
コンパイル時間 1,490 ms
コンパイル使用メモリ 168,444 KB
実行使用メモリ 218,368 KB
最終ジャッジ日時 2024-10-13 08:44:56
合計ジャッジ時間 4,174 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

ll dp[305][305][305];
const int mod=1e9+7;

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