結果

問題 No.1111 コード進行
ユーザー face4
提出日時 2020-07-16 12:44:16
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 665 bytes
コンパイル時間 776 ms
コンパイル使用メモリ 71,324 KB
実行使用メモリ 109,696 KB
最終ジャッジ日時 2024-11-24 13:16:56
合計ジャッジ時間 2,783 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

int dp[300][301][301] = {}; // MLE?
const int mod = 1000000007;

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> p(m), q(m), c(m);
    while(m--){
        cin >> p[m] >> q[m] >> c[m];
    }
    for(int j = 1; j <= 300; j++)   dp[0][j][0] = 1;
    for(int i = 0; i+1 < n; i++){
        for(int j = 0; j < p.size(); j++){
            for(int x = 0; x+c[j] <= k; x++){
                (dp[i+1][q[j]][x+c[j]] += dp[i][p[j]][x]) %= mod;
            }
        }
    }
    int ans = 0;
    for(int j = 1; j <= 300; j++)   (ans += dp[n-1][j][k]) %= mod;
    cout << ans << endl;
    return 0;
}
0