結果

問題 No.1111 コード進行
ユーザー noritakenoritake
提出日時 2020-07-11 10:28:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,438 bytes
コンパイル時間 1,646 ms
コンパイル使用メモリ 172,240 KB
実行使用メモリ 121,980 KB
最終ジャッジ日時 2023-08-02 20:33:12
合計ジャッジ時間 18,133 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
117,740 KB
testcase_01 AC 84 ms
117,652 KB
testcase_02 AC 84 ms
117,644 KB
testcase_03 AC 84 ms
117,588 KB
testcase_04 AC 83 ms
117,676 KB
testcase_05 AC 83 ms
117,556 KB
testcase_06 AC 166 ms
117,552 KB
testcase_07 AC 266 ms
117,588 KB
testcase_08 AC 329 ms
117,544 KB
testcase_09 AC 121 ms
117,632 KB
testcase_10 AC 188 ms
117,736 KB
testcase_11 AC 196 ms
117,548 KB
testcase_12 AC 210 ms
117,544 KB
testcase_13 AC 119 ms
117,548 KB
testcase_14 AC 317 ms
117,588 KB
testcase_15 AC 210 ms
117,560 KB
testcase_16 AC 238 ms
117,544 KB
testcase_17 AC 109 ms
117,548 KB
testcase_18 AC 96 ms
117,560 KB
testcase_19 AC 84 ms
117,548 KB
testcase_20 AC 101 ms
117,648 KB
testcase_21 AC 173 ms
117,656 KB
testcase_22 AC 120 ms
117,632 KB
testcase_23 AC 179 ms
117,656 KB
testcase_24 AC 128 ms
117,544 KB
testcase_25 AC 469 ms
117,736 KB
testcase_26 AC 291 ms
117,660 KB
testcase_27 AC 103 ms
117,736 KB
testcase_28 AC 167 ms
117,604 KB
testcase_29 AC 672 ms
117,632 KB
testcase_30 AC 839 ms
117,740 KB
testcase_31 AC 105 ms
117,592 KB
testcase_32 TLE -
testcase_33 AC 1,687 ms
117,708 KB
testcase_34 AC 153 ms
117,604 KB
testcase_35 AC 243 ms
117,872 KB
testcase_36 TLE -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます

ソースコード

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];
    }

    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 < MAX; s++) {
                for (int k = 0; k < M; k++) {
                    if (j != P[k]) continue;
                    if (s + C[k] >= MAX) continue;

                    dp[i + 1][Q[k]][s + C[k]] += dp[i][j][s];
                    dp[i + 1][Q[k]][s + C[k]] %= MOD;
                }
            }
        }
    }

    // rep(i, N + 1) {
    //     cout << "i: " << i << endl;
    //     rep(j, MAX) {
    //         cout << "  j: " << j << endl;
    //         rep(k, MAX) {
    //             cout << "    " << dp[i][j][k] << " ";
    //         }
    //         cout << endl;
    //     }
    // }

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

    cout << ans << endl;
}
0