結果

問題 No.1111 コード進行
ユーザー trineutrontrineutron
提出日時 2020-02-15 01:39:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,445 bytes
コンパイル時間 2,570 ms
コンパイル使用メモリ 211,000 KB
実行使用メモリ 217,728 KB
最終ジャッジ日時 2024-04-16 03:04:10
合計ジャッジ時間 8,351 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,632 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 7 ms
7,424 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 87 ms
110,336 KB
testcase_29 AC 42 ms
47,744 KB
testcase_30 AC 69 ms
73,984 KB
testcase_31 AC 11 ms
14,848 KB
testcase_32 AC 77 ms
67,072 KB
testcase_33 AC 64 ms
44,160 KB
testcase_34 AC 63 ms
80,256 KB
testcase_35 AC 83 ms
102,912 KB
testcase_36 AC 149 ms
108,800 KB
testcase_37 AC 43 ms
29,568 KB
testcase_38 AC 33 ms
22,528 KB
testcase_39 AC 102 ms
72,704 KB
testcase_40 AC 127 ms
100,608 KB
testcase_41 AC 103 ms
122,496 KB
testcase_42 AC 73 ms
51,456 KB
testcase_43 AC 65 ms
45,184 KB
testcase_44 AC 26 ms
26,112 KB
testcase_45 AC 77 ms
75,392 KB
testcase_46 AC 10 ms
8,576 KB
testcase_47 AC 336 ms
217,728 KB
testcase_48 AC 11 ms
8,576 KB
testcase_49 RE -
権限があれば一括ダウンロードができます

ソースコード

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++) {
        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