結果

問題 No.1111 コード進行
ユーザー trineutrontrineutron
提出日時 2019-11-04 12:27:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,198 bytes
コンパイル時間 2,063 ms
コンパイル使用メモリ 176,272 KB
実行使用メモリ 225,056 KB
最終ジャッジ日時 2024-04-09 05:10:04
合計ジャッジ時間 35,005 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
13,892 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 2 ms
6,948 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 20 ms
6,944 KB
testcase_06 AC 76 ms
7,808 KB
testcase_07 AC 83 ms
7,424 KB
testcase_08 AC 24 ms
6,944 KB
testcase_09 AC 31 ms
6,944 KB
testcase_10 AC 139 ms
9,856 KB
testcase_11 AC 24 ms
6,948 KB
testcase_12 AC 78 ms
7,808 KB
testcase_13 AC 55 ms
6,944 KB
testcase_14 AC 133 ms
10,240 KB
testcase_15 AC 19 ms
6,948 KB
testcase_16 AC 91 ms
8,576 KB
testcase_17 AC 146 ms
10,368 KB
testcase_18 AC 25 ms
6,944 KB
testcase_19 AC 3 ms
6,948 KB
testcase_20 AC 27 ms
6,948 KB
testcase_21 AC 10 ms
6,944 KB
testcase_22 AC 181 ms
12,288 KB
testcase_23 AC 62 ms
6,948 KB
testcase_24 AC 72 ms
7,168 KB
testcase_25 AC 172 ms
11,648 KB
testcase_26 AC 98 ms
7,808 KB
testcase_27 AC 11 ms
6,944 KB
testcase_28 TLE -
testcase_29 AC 1,136 ms
48,128 KB
testcase_30 AC 1,641 ms
74,112 KB
testcase_31 AC 253 ms
15,360 KB
testcase_32 AC 1,621 ms
67,584 KB
testcase_33 AC 958 ms
44,288 KB
testcase_34 AC 1,773 ms
80,640 KB
testcase_35 TLE -
testcase_36 TLE -
testcase_37 AC 567 ms
29,824 KB
testcase_38 AC 417 ms
22,784 KB
testcase_39 AC 1,633 ms
73,088 KB
testcase_40 TLE -
testcase_41 TLE -
testcase_42 AC 1,247 ms
51,840 KB
testcase_43 AC 1,024 ms
45,568 KB
testcase_44 AC 476 ms
26,240 KB
testcase_45 AC 1,717 ms
75,776 KB
testcase_46 AC 141 ms
8,576 KB
testcase_47 TLE -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    const long mod = 1000000007;
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> p(m), q(m), c(m);
    vector<vector<int>> cost(300, vector<int>(300, -1));
    for (int i = 0; i < m; i++) {
        cin >> p.at(i) >> q.at(i) >> c.at(i);
        p.at(i)--; q.at(i)--;
        cost.at(p.at(i)).at(q.at(i)) = c.at(i);
    }
    vector<vector<vector<long>>> dp(n - 1, vector<vector<long>>(300, vector<long>(k + 1)));
    for (int i = 0; i < m; i++) {
        if (c.at(i) <= k) dp.at(0).at(q.at(i)).at(c.at(i))++;
    }
    for (int i = 1; i < n - 1; i++) {
        for (int j = 0; j < 300; j++) {
            for (int l = 0; l < 300; l++) {
                for (int comp = cost.at(j).at(l); comp <= k; comp++) {
                    if (cost.at(j).at(l) >= 0) {
                        dp.at(i).at(l).at(comp) += dp.at(i - 1).at(j).at(comp - cost.at(j).at(l));
                        dp.at(i).at(l).at(comp) %= mod;
                    }
                }
            }
        }
    }
    long ans = 0;
    for (int i = 0; i < 300; i++) {
        ans += dp.at(n - 2).at(i).at(k);
        ans %= mod;
    }
    cout << ans << endl;
}
0