結果

問題 No.1111 コード進行
ユーザー noritakenoritake
提出日時 2020-07-11 11:15:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,036 ms / 2,000 ms
コード長 1,267 bytes
コンパイル時間 1,959 ms
コンパイル使用メモリ 180,892 KB
実行使用メモリ 116,480 KB
最終ジャッジ日時 2024-04-20 21:56:06
合計ジャッジ時間 14,128 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,760 KB
testcase_01 AC 5 ms
5,376 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 5 ms
5,376 KB
testcase_06 AC 21 ms
6,944 KB
testcase_07 AC 41 ms
9,088 KB
testcase_08 AC 47 ms
8,704 KB
testcase_09 AC 11 ms
5,632 KB
testcase_10 AC 35 ms
10,880 KB
testcase_11 AC 27 ms
7,808 KB
testcase_12 AC 29 ms
6,940 KB
testcase_13 AC 14 ms
6,784 KB
testcase_14 AC 45 ms
8,448 KB
testcase_15 AC 34 ms
9,984 KB
testcase_16 AC 31 ms
7,552 KB
testcase_17 AC 26 ms
10,752 KB
testcase_18 AC 17 ms
8,448 KB
testcase_19 AC 5 ms
5,376 KB
testcase_20 AC 8 ms
5,504 KB
testcase_21 AC 27 ms
9,216 KB
testcase_22 AC 28 ms
10,368 KB
testcase_23 AC 25 ms
8,064 KB
testcase_24 AC 16 ms
7,552 KB
testcase_25 AC 74 ms
10,752 KB
testcase_26 AC 44 ms
9,728 KB
testcase_27 AC 7 ms
5,376 KB
testcase_28 AC 232 ms
70,912 KB
testcase_29 AC 243 ms
67,968 KB
testcase_30 AC 218 ms
47,744 KB
testcase_31 AC 32 ms
12,928 KB
testcase_32 AC 601 ms
88,320 KB
testcase_33 AC 282 ms
31,744 KB
testcase_34 AC 191 ms
60,288 KB
testcase_35 AC 336 ms
102,912 KB
testcase_36 AC 577 ms
71,680 KB
testcase_37 AC 540 ms
66,688 KB
testcase_38 AC 441 ms
48,512 KB
testcase_39 AC 410 ms
45,440 KB
testcase_40 AC 572 ms
75,520 KB
testcase_41 AC 302 ms
82,944 KB
testcase_42 AC 538 ms
70,912 KB
testcase_43 AC 426 ms
46,592 KB
testcase_44 AC 208 ms
42,112 KB
testcase_45 AC 327 ms
69,760 KB
testcase_46 AC 980 ms
116,224 KB
testcase_47 AC 1,026 ms
116,224 KB
testcase_48 AC 1,026 ms
116,480 KB
testcase_49 AC 1,036 ms
116,224 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;

    map<int, vector<pair<int, int>>> G;
    rep(i, M) {
        int x, y, z;
        cin >> x >> y >> z;

        G[x].push_back(make_pair(y, z));
    }

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

    vector<vector<vector<int>>> dp(N + 1, vector<vector<int>>(MAX, vector<int>(MAX)));
    for (auto x : G) {
        for (int i = 0; i < x.second.size(); i++) {
            dp[1][x.second[i].first][x.second[i].second]++;
        }
    }

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

                for (int l = 0; l < G[j].size(); l++) {
                    int nj = G[j][l].first;
                    int ncost = G[j][l].second;
                    
                    if (k + ncost > K) continue;

                    dp[i + 1][nj][k + ncost] += dp[i][j][k];
                    dp[i + 1][nj][k + ncost] %= MOD;
                }
            }
        }
    }

    int ans = 0;

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