結果

問題 No.1111 コード進行
ユーザー nanophoto12nanophoto12
提出日時 2020-07-24 21:55:04
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 1,269 bytes
コンパイル時間 2,284 ms
コンパイル使用メモリ 205,940 KB
実行使用メモリ 121,996 KB
最終ジャッジ日時 2023-09-08 04:02:25
合計ジャッジ時間 5,452 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 5 ms
6,724 KB
testcase_06 AC 6 ms
8,416 KB
testcase_07 AC 6 ms
7,200 KB
testcase_08 AC 3 ms
4,536 KB
testcase_09 AC 5 ms
6,684 KB
testcase_10 AC 7 ms
9,580 KB
testcase_11 AC 3 ms
4,580 KB
testcase_12 AC 6 ms
7,920 KB
testcase_13 AC 5 ms
6,928 KB
testcase_14 AC 8 ms
9,544 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 7 ms
8,720 KB
testcase_17 AC 7 ms
9,680 KB
testcase_18 AC 2 ms
4,496 KB
testcase_19 AC 3 ms
4,380 KB
testcase_20 AC 4 ms
5,884 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 9 ms
12,472 KB
testcase_23 AC 4 ms
6,280 KB
testcase_24 AC 5 ms
6,944 KB
testcase_25 AC 10 ms
11,740 KB
testcase_26 AC 6 ms
7,452 KB
testcase_27 AC 3 ms
4,380 KB
testcase_28 AC 80 ms
104,400 KB
testcase_29 AC 38 ms
46,560 KB
testcase_30 AC 60 ms
71,400 KB
testcase_31 AC 11 ms
15,132 KB
testcase_32 AC 65 ms
65,280 KB
testcase_33 AC 50 ms
44,196 KB
testcase_34 AC 49 ms
60,232 KB
testcase_35 AC 82 ms
102,468 KB
testcase_36 AC 123 ms
109,572 KB
testcase_37 AC 38 ms
29,544 KB
testcase_38 AC 28 ms
22,600 KB
testcase_39 AC 81 ms
70,196 KB
testcase_40 AC 108 ms
100,160 KB
testcase_41 AC 99 ms
121,996 KB
testcase_42 AC 63 ms
51,824 KB
testcase_43 AC 56 ms
45,748 KB
testcase_44 AC 27 ms
25,980 KB
testcase_45 AC 71 ms
76,344 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 104 ms
17,572 KB
testcase_48 AC 11 ms
8,248 KB
testcase_49 AC 11 ms
8,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

const ll mod = 1000000007;

template<typename T>
void chmin(T & ref, const T  value) {
	if (ref > value) ref = value;
}

int main() {
	//dp[i][j][k]...i回目にて最後がjで複雑度合計がk
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> ps(m, 0), qs(m,0), cs(m,0);
	ll u = 0;
	rep(i, m) {
		cin >> ps[i] >> qs[i] >> cs[i];
		ps[i]--;
		qs[i]--;
		u = max(u, ps[i]);
		u = max(u, qs[i]);
	}
	u++;
	vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(u, vector<ll>(k+1, 0)));
	rep(i, u) {
		dp[0][i][0] = 1;
	}
	for (int i = 0; i < n-1; i++) {
		for (int j = 0; j < m; j++) {
			for (int p = 0; p <= k; p++) {
				ll np = p + cs[j];
				if (np <= k) {
					(dp[i + 1][qs[j]][np] += dp[i][ps[j]][p]) %= mod;
				}
			}
		}
	}
	ll sum = 0;
	rep(i, u) {
		(sum += dp[n-1][i][k]) %= mod;
	}
	cout << sum << endl;
	
	return 0;
}
0