結果

問題 No.1111 コード進行
ユーザー けーむけーむ
提出日時 2020-07-20 17:28:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 2,345 bytes
コンパイル時間 2,775 ms
コンパイル使用メモリ 175,136 KB
実行使用メモリ 219,124 KB
最終ジャッジ日時 2023-08-25 18:19:04
合計ジャッジ時間 5,767 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,416 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 5 ms
6,712 KB
testcase_06 AC 6 ms
8,628 KB
testcase_07 AC 6 ms
7,872 KB
testcase_08 AC 4 ms
5,080 KB
testcase_09 AC 5 ms
6,660 KB
testcase_10 AC 9 ms
10,368 KB
testcase_11 AC 4 ms
5,356 KB
testcase_12 AC 7 ms
8,524 KB
testcase_13 AC 5 ms
7,264 KB
testcase_14 AC 8 ms
10,908 KB
testcase_15 AC 4 ms
4,592 KB
testcase_16 AC 8 ms
9,088 KB
testcase_17 AC 8 ms
10,672 KB
testcase_18 AC 4 ms
5,244 KB
testcase_19 AC 3 ms
4,960 KB
testcase_20 AC 5 ms
6,244 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 11 ms
12,772 KB
testcase_23 AC 5 ms
6,920 KB
testcase_24 AC 6 ms
7,792 KB
testcase_25 AC 11 ms
12,012 KB
testcase_26 AC 7 ms
8,372 KB
testcase_27 AC 3 ms
5,148 KB
testcase_28 AC 99 ms
111,280 KB
testcase_29 AC 52 ms
48,560 KB
testcase_30 AC 68 ms
74,796 KB
testcase_31 AC 13 ms
15,900 KB
testcase_32 AC 76 ms
67,964 KB
testcase_33 AC 45 ms
45,056 KB
testcase_34 AC 74 ms
81,300 KB
testcase_35 AC 102 ms
103,928 KB
testcase_36 AC 118 ms
109,908 KB
testcase_37 AC 44 ms
30,308 KB
testcase_38 AC 31 ms
23,384 KB
testcase_39 AC 75 ms
73,764 KB
testcase_40 AC 107 ms
101,464 KB
testcase_41 AC 113 ms
123,372 KB
testcase_42 AC 67 ms
52,348 KB
testcase_43 AC 53 ms
46,044 KB
testcase_44 AC 30 ms
26,788 KB
testcase_45 AC 80 ms
76,396 KB
testcase_46 AC 32 ms
8,808 KB
testcase_47 AC 226 ms
219,124 KB
testcase_48 AC 33 ms
8,808 KB
testcase_49 AC 32 ms
8,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

struct mint {
    constexpr static int mod = 1000000007;
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};

const ll inf = LONG_LONG_MAX / 2 - 1;
ll n, m, k;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin >> n >> m >> k;
    vector<vector<ll>> g(300, vector<ll>(300, inf));
    rep(i, m) {
        ll p, q, c;
        cin >> p >> q >> c;
        p--; q--;
        g[p][q] = c;
    }
    vector<vector<vector<mint>>> dp(n, vector<vector<mint>>(300, vector<mint>(k + 1, 0)));
    rep(i, 300) dp[0][i][0] = 1;
    rep(i, n - 1) {
        rep(j, 300) {
            rep(o, 300) {
                if (g[j][o] == inf) continue;
                rep(p, k + 1 - g[j][o]) {
                    dp[i + 1][o][p + g[j][o]] += dp[i][j][p];
                }
            }
        }
    }
    mint ans = 0;
    rep(i, 300) ans += dp[n - 1][i][k];
    cout << ans.x << endl;
    return 0;
}
0