結果

問題 No.1111 コード進行
ユーザー trineutrontrineutron
提出日時 2019-11-02 22:46:04
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 1,464 bytes
コンパイル時間 2,109 ms
コンパイル使用メモリ 166,272 KB
実行使用メモリ 217,600 KB
最終ジャッジ日時 2024-05-07 19:54:18
合計ジャッジ時間 4,873 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 4 ms
7,424 KB
testcase_07 AC 4 ms
7,168 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,504 KB
testcase_10 AC 6 ms
9,472 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 5 ms
7,552 KB
testcase_13 AC 4 ms
6,272 KB
testcase_14 AC 7 ms
9,728 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 5 ms
8,064 KB
testcase_17 AC 5 ms
9,728 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 7 ms
11,648 KB
testcase_23 AC 4 ms
6,144 KB
testcase_24 AC 4 ms
6,784 KB
testcase_25 AC 9 ms
11,136 KB
testcase_26 AC 5 ms
7,552 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 82 ms
110,208 KB
testcase_29 AC 37 ms
47,872 KB
testcase_30 AC 60 ms
73,728 KB
testcase_31 AC 9 ms
14,848 KB
testcase_32 AC 64 ms
67,200 KB
testcase_33 AC 48 ms
44,032 KB
testcase_34 AC 56 ms
80,256 KB
testcase_35 AC 78 ms
102,912 KB
testcase_36 AC 122 ms
108,800 KB
testcase_37 AC 35 ms
29,440 KB
testcase_38 AC 25 ms
22,528 KB
testcase_39 AC 78 ms
72,704 KB
testcase_40 AC 104 ms
100,352 KB
testcase_41 AC 94 ms
122,496 KB
testcase_42 AC 57 ms
51,328 KB
testcase_43 AC 49 ms
45,184 KB
testcase_44 AC 22 ms
25,984 KB
testcase_45 AC 62 ms
75,264 KB
testcase_46 AC 9 ms
8,448 KB
testcase_47 AC 260 ms
217,600 KB
testcase_48 AC 10 ms
8,448 KB
testcase_49 AC 8 ms
8,448 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