結果

問題 No.1111 コード進行
ユーザー noritakenoritake
提出日時 2020-07-14 21:56:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,054 bytes
コンパイル時間 1,776 ms
コンパイル使用メモリ 173,904 KB
実行使用メモリ 123,136 KB
最終ジャッジ日時 2024-04-29 16:13:20
合計ジャッジ時間 6,358 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 232 ms
123,136 KB
testcase_01 AC 116 ms
117,632 KB
testcase_02 WA -
testcase_03 AC 115 ms
117,760 KB
testcase_04 AC 142 ms
117,760 KB
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
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;
typedef vector<int> vi;
typedef vector<long long> vl;

int main() {
    int N, M, K;
    cin >> N >> M >> K;

    vi P(M), Q(M), C(M);
    rep(i, M) {
        cin >> P[i] >> Q[i] >> C[i];
        P[i]--; Q[i]--;
    }

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

    vector<vector<vi>> dp(MAX, vector<vi>(MAX, vi(MAX)));
    rep(i, M) {
        dp[2][Q[i]][C[i]]++;
    }

    for (int i = 2; i < MAX - 1; i++) {
        for (int j = 0; j < MAX; j++) {
            for (int k = 0; k < MAX; k++) {

                for (int l = 0; l < M; l++) {
                    if (j != P[l]) continue;
                    if (k + C[l] >= MAX) continue;

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

    int cnt = 0;
    rep(i, M) {
        cnt += dp[N][i][K];
        cnt %= MOD;
    }
    cout << cnt << endl;
}
0