結果

問題 No.1111 コード進行
ユーザー noritakenoritake
提出日時 2020-07-11 10:45:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,094 ms / 2,000 ms
コード長 1,306 bytes
コンパイル時間 1,765 ms
コンパイル使用メモリ 178,564 KB
実行使用メモリ 117,888 KB
最終ジャッジ日時 2024-04-20 21:03:11
合計ジャッジ時間 12,234 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
117,760 KB
testcase_01 AC 85 ms
117,632 KB
testcase_02 AC 87 ms
117,632 KB
testcase_03 AC 88 ms
117,760 KB
testcase_04 AC 90 ms
117,632 KB
testcase_05 AC 88 ms
117,632 KB
testcase_06 AC 99 ms
117,760 KB
testcase_07 AC 106 ms
117,888 KB
testcase_08 AC 94 ms
117,888 KB
testcase_09 AC 92 ms
117,888 KB
testcase_10 AC 100 ms
117,760 KB
testcase_11 AC 89 ms
117,888 KB
testcase_12 AC 105 ms
117,888 KB
testcase_13 AC 94 ms
117,760 KB
testcase_14 AC 119 ms
117,888 KB
testcase_15 AC 93 ms
117,760 KB
testcase_16 AC 111 ms
117,760 KB
testcase_17 AC 99 ms
117,760 KB
testcase_18 AC 88 ms
117,760 KB
testcase_19 AC 85 ms
117,760 KB
testcase_20 AC 91 ms
117,760 KB
testcase_21 AC 90 ms
117,888 KB
testcase_22 AC 105 ms
117,760 KB
testcase_23 AC 94 ms
117,760 KB
testcase_24 AC 95 ms
117,760 KB
testcase_25 AC 129 ms
117,888 KB
testcase_26 AC 102 ms
117,888 KB
testcase_27 AC 89 ms
117,888 KB
testcase_28 AC 235 ms
117,760 KB
testcase_29 AC 163 ms
117,632 KB
testcase_30 AC 237 ms
117,632 KB
testcase_31 AC 102 ms
117,632 KB
testcase_32 AC 301 ms
117,888 KB
testcase_33 AC 289 ms
117,760 KB
testcase_34 AC 195 ms
117,632 KB
testcase_35 AC 252 ms
117,632 KB
testcase_36 AC 500 ms
117,760 KB
testcase_37 AC 212 ms
117,760 KB
testcase_38 AC 189 ms
117,888 KB
testcase_39 AC 406 ms
117,888 KB
testcase_40 AC 459 ms
117,760 KB
testcase_41 AC 293 ms
117,760 KB
testcase_42 AC 304 ms
117,760 KB
testcase_43 AC 300 ms
117,888 KB
testcase_44 AC 147 ms
117,760 KB
testcase_45 AC 249 ms
117,888 KB
testcase_46 AC 92 ms
117,760 KB
testcase_47 AC 1,094 ms
117,760 KB
testcase_48 AC 107 ms
117,760 KB
testcase_49 AC 107 ms
117,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> P(M), Q(M), C(M);
    rep(i, M) {
        P[i]--;
        Q[i]--;
        cin >> P[i] >> Q[i] >> C[i];
    }

    map<int, vector<pair<int, int>>> G;
    rep(i, M) {
        G[P[i]].push_back(make_pair(Q[i], C[i]));
    }

    const int MAX = 305;
    // const int MAX = 10;
    const int MOD = 1000000007;

    vector<vector<vector<int>>> dp(MAX, vector<vector<int>>(MAX, vector<int>(MAX)));
    for (int i = 0; i < M; i++) {
        dp[1][Q[i]][C[i]]++;
    }

    // コード数
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < MAX; j++) {
            // 複雑さ
            for (int s = 0; s <= K; s++) {

                for (int k = 0; k < G[j].size(); k++) {
                    int nj = G[j][k].first;
                    int nc = G[j][k].second;

                    if (s + nc > K) continue;

                    dp[i + 1][nj][s + nc] += dp[i][j][s];
                    dp[i + 1][nj][s + nc] %= MOD;
                }
            }
        }
    }

    int ans = 0;
    for (int x = 0; x < MAX; x++) {
        ans += dp[N - 1][x][K];
        ans %= MOD;
    }

    cout << ans << endl;
}
0