結果

問題 No.1111 コード進行
ユーザー ぷらぷら
提出日時 2021-03-14 19:46:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 332 ms / 2,000 ms
コード長 949 bytes
コンパイル時間 1,758 ms
コンパイル使用メモリ 168,184 KB
実行使用メモリ 219,136 KB
最終ジャッジ日時 2024-04-24 02:10:12
合計ジャッジ時間 5,607 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 5 ms
5,632 KB
testcase_07 AC 6 ms
5,760 KB
testcase_08 AC 9 ms
6,656 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 6 ms
5,376 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 AC 5 ms
5,376 KB
testcase_13 AC 5 ms
5,376 KB
testcase_14 AC 7 ms
5,504 KB
testcase_15 AC 8 ms
7,296 KB
testcase_16 AC 6 ms
6,016 KB
testcase_17 AC 7 ms
5,376 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 5 ms
5,376 KB
testcase_22 AC 6 ms
6,400 KB
testcase_23 AC 6 ms
6,144 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 11 ms
7,680 KB
testcase_26 AC 8 ms
5,888 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 26 ms
7,552 KB
testcase_29 AC 41 ms
20,864 KB
testcase_30 AC 31 ms
13,952 KB
testcase_31 AC 6 ms
5,376 KB
testcase_32 AC 73 ms
22,400 KB
testcase_33 AC 36 ms
13,440 KB
testcase_34 AC 22 ms
7,168 KB
testcase_35 AC 39 ms
11,008 KB
testcase_36 AC 166 ms
109,952 KB
testcase_37 AC 158 ms
103,680 KB
testcase_38 AC 96 ms
55,040 KB
testcase_39 AC 60 ms
27,520 KB
testcase_40 AC 143 ms
92,288 KB
testcase_41 AC 54 ms
28,288 KB
testcase_42 AC 158 ms
106,496 KB
testcase_43 AC 97 ms
59,776 KB
testcase_44 AC 57 ms
38,784 KB
testcase_45 AC 85 ms
56,064 KB
testcase_46 AC 124 ms
19,712 KB
testcase_47 AC 123 ms
19,712 KB
testcase_48 AC 332 ms
219,136 KB
testcase_49 AC 329 ms
219,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int mod = 1e9+7;
long long dp[305][305][305];

int main() {
    int N,M,K;
    cin >> N >> M >> K;
    vector<vector<pair<int,int>>>road(300);
    for(int i = 0; i < M; i++) {
        int P,Q,C;
        cin >> P >> Q >> C;
        P--;
        Q--;
        road[P].push_back({Q,C});
    }
    for(int i = 0; i < 300; i++) {
        dp[0][i][0] = 1;
    }
    for(int i = 0; i < N-1; i++) {
        for(int j = 0; j < 300; j++) {
            for(int k = 0; k <= 300; k++) {
                for(auto l:road[j]) {
                    if(k+l.second <= 300) {
                        dp[i+1][l.first][k+l.second] += dp[i][j][k];
                        dp[i+1][l.first][k+l.second] %= mod;
                    }
                }
            }
        }
    }
    long long ans = 0;
    for(int i = 0; i < 300; i++) {
        ans += dp[N-1][i][K];
        ans %= mod;
    }
    cout << ans << endl;
}
0