結果

問題 No.1111 コード進行
ユーザー trineutrontrineutron
提出日時 2019-10-13 18:59:05
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 331 ms / 2,000 ms
コード長 1,463 bytes
コンパイル時間 2,384 ms
コンパイル使用メモリ 181,468 KB
実行使用メモリ 217,856 KB
最終ジャッジ日時 2024-04-09 03:38:05
合計ジャッジ時間 5,564 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,820 KB
testcase_01 AC 2 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 3 ms
6,944 KB
testcase_06 AC 6 ms
7,552 KB
testcase_07 AC 5 ms
7,040 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 4 ms
6,944 KB
testcase_10 AC 8 ms
9,600 KB
testcase_11 AC 4 ms
6,948 KB
testcase_12 AC 6 ms
7,552 KB
testcase_13 AC 4 ms
6,944 KB
testcase_14 AC 8 ms
9,728 KB
testcase_15 AC 3 ms
6,944 KB
testcase_16 AC 6 ms
8,192 KB
testcase_17 AC 6 ms
9,856 KB
testcase_18 AC 2 ms
6,948 KB
testcase_19 AC 3 ms
6,944 KB
testcase_20 AC 4 ms
6,948 KB
testcase_21 AC 3 ms
6,948 KB
testcase_22 AC 9 ms
11,776 KB
testcase_23 AC 4 ms
6,944 KB
testcase_24 AC 4 ms
7,040 KB
testcase_25 AC 10 ms
11,264 KB
testcase_26 AC 7 ms
7,424 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 86 ms
110,208 KB
testcase_29 AC 41 ms
47,744 KB
testcase_30 AC 68 ms
73,856 KB
testcase_31 AC 10 ms
14,848 KB
testcase_32 AC 74 ms
67,200 KB
testcase_33 AC 62 ms
44,032 KB
testcase_34 AC 61 ms
80,384 KB
testcase_35 AC 81 ms
102,784 KB
testcase_36 AC 151 ms
108,800 KB
testcase_37 AC 43 ms
29,440 KB
testcase_38 AC 33 ms
22,528 KB
testcase_39 AC 101 ms
72,704 KB
testcase_40 AC 128 ms
100,352 KB
testcase_41 AC 102 ms
122,368 KB
testcase_42 AC 71 ms
51,584 KB
testcase_43 AC 65 ms
45,184 KB
testcase_44 AC 26 ms
25,984 KB
testcase_45 AC 73 ms
75,392 KB
testcase_46 AC 10 ms
8,704 KB
testcase_47 AC 331 ms
217,856 KB
testcase_48 AC 10 ms
8,448 KB
testcase_49 AC 10 ms
8,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    const long mod = 1000000007;
    int n, m, k;
    cin >> n >> m >> k;
    assert(2 <= n && n <= 300);
    assert(1 <= m && m <= 300);
    assert(0 <= k && k <= 300);
    vector<int> p(m), q(m), c(m);
    vector<pair<int, int>> check;
    for (int i = 0; i < m; i++) {
        cin >> p.at(i) >> q.at(i) >> c.at(i);
        assert(1 <= p.at(i) && p.at(i) <= 300);
        assert(1 <= q.at(i) && q.at(i) <= 300);
        assert(p.at(i) != q.at(i));
        assert(0 <= c.at(i) && c.at(i) <= 300);
        check.emplace_back(p.at(i), q.at(i));
    }
    sort(check.begin(), check.end());
    for (int i = 0; i < m - 1; i++) {
        assert(check.at(i) != check.at(i + 1));
    }
    for (int i = 0; i < m; i++) {
        p.at(i)--; q.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 < m; j++) {
            for (int comp = c.at(j); comp <= k; comp++) {
                dp.at(i).at(q.at(j)).at(comp) += dp.at(i - 1).at(p.at(j)).at(comp - c.at(j));
                dp.at(i).at(q.at(j)).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