結果

問題 No.1111 コード進行
ユーザー cn_449cn_449
提出日時 2020-07-10 21:39:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 1,786 bytes
コンパイル時間 1,004 ms
コンパイル使用メモリ 116,056 KB
実行使用メモリ 224,420 KB
最終ジャッジ日時 2024-04-19 16:23:12
合計ジャッジ時間 3,398 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 3 ms
10,248 KB
testcase_07 AC 5 ms
14,312 KB
testcase_08 AC 4 ms
12,584 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 5 ms
16,764 KB
testcase_11 AC 4 ms
10,500 KB
testcase_12 AC 4 ms
10,516 KB
testcase_13 AC 3 ms
8,708 KB
testcase_14 AC 5 ms
12,624 KB
testcase_15 AC 4 ms
16,584 KB
testcase_16 AC 5 ms
10,384 KB
testcase_17 AC 4 ms
18,060 KB
testcase_18 AC 3 ms
8,352 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 3 ms
6,948 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 4 ms
16,224 KB
testcase_23 AC 4 ms
12,636 KB
testcase_24 AC 4 ms
10,628 KB
testcase_25 AC 6 ms
17,016 KB
testcase_26 AC 6 ms
16,144 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 23 ms
85,328 KB
testcase_29 AC 23 ms
87,140 KB
testcase_30 AC 26 ms
82,984 KB
testcase_31 AC 5 ms
20,828 KB
testcase_32 AC 42 ms
89,732 KB
testcase_33 AC 32 ms
59,300 KB
testcase_34 AC 19 ms
82,680 KB
testcase_35 AC 23 ms
85,224 KB
testcase_36 AC 67 ms
126,000 KB
testcase_37 AC 45 ms
114,504 KB
testcase_38 AC 35 ms
88,308 KB
testcase_39 AC 45 ms
83,356 KB
testcase_40 AC 62 ms
119,180 KB
testcase_41 AC 32 ms
94,680 KB
testcase_42 AC 51 ms
120,284 KB
testcase_43 AC 40 ms
86,884 KB
testcase_44 AC 23 ms
80,536 KB
testcase_45 AC 38 ms
100,680 KB
testcase_46 AC 43 ms
91,828 KB
testcase_47 AC 127 ms
92,336 KB
testcase_48 AC 102 ms
224,420 KB
testcase_49 AC 116 ms
186,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n';
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 1000000007;
ll dp[310][310][310];

struct edge {
	ll from, to, cost;
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	ll n, m, k;
	cin >> n >> m >> k;
	vector<edge> a(m);
	rep(i, m) {
		ll u, v, c;
		cin >> u >> v >> c;
		u--; v--;
		a[i] = { u,v,c };
	}
	rep(i, 310) dp[0][i][0] = 1;
	rep(i, n - 1) {
		rep(j, m) {
			rep(x, 310) {
				if (x + a[j].cost <= k) {
					dp[i + 1][a[j].to][x + a[j].cost] += dp[i][a[j].from][x];
					dp[i + 1][a[j].to][x + a[j].cost] %= mod;
				}
			}
		}
	}
	ll ans = 0;
	rep(i, 310) ans += dp[n - 1][i][k];
	cout << ans % mod << '\n';
}
0