結果

問題 No.1111 コード進行
ユーザー snrnsidysnrnsidy
提出日時 2021-06-14 02:18:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 215 ms / 2,000 ms
コード長 916 bytes
コンパイル時間 1,997 ms
コンパイル使用メモリ 202,024 KB
実行使用メモリ 215,600 KB
最終ジャッジ日時 2023-08-25 11:04:31
合計ジャッジ時間 6,169 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,420 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,808 KB
testcase_07 AC 3 ms
4,576 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,636 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 3 ms
4,904 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 5 ms
5,312 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 4 ms
5,244 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 4 ms
4,376 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 3 ms
4,600 KB
testcase_25 AC 6 ms
6,576 KB
testcase_26 AC 5 ms
5,324 KB
testcase_27 AC 2 ms
4,388 KB
testcase_28 AC 12 ms
4,380 KB
testcase_29 AC 13 ms
9,640 KB
testcase_30 AC 24 ms
13,040 KB
testcase_31 AC 4 ms
4,600 KB
testcase_32 AC 35 ms
18,604 KB
testcase_33 AC 29 ms
12,532 KB
testcase_34 AC 12 ms
5,828 KB
testcase_35 AC 12 ms
4,376 KB
testcase_36 AC 18 ms
10,480 KB
testcase_37 AC 23 ms
22,032 KB
testcase_38 AC 51 ms
44,168 KB
testcase_39 AC 53 ms
26,476 KB
testcase_40 AC 103 ms
75,840 KB
testcase_41 AC 14 ms
4,384 KB
testcase_42 AC 42 ms
37,444 KB
testcase_43 AC 69 ms
52,616 KB
testcase_44 AC 5 ms
4,860 KB
testcase_45 AC 9 ms
4,416 KB
testcase_46 AC 19 ms
18,648 KB
testcase_47 AC 36 ms
18,844 KB
testcase_48 AC 215 ms
215,600 KB
testcase_49 AC 5 ms
5,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const long long int MOD = 1e9 + 7;
vector <pair<int, int>> adj[301];
long long int dp[301][301][301];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M, K, a, b, c;

	cin >> N >> M >> K;

	for (int i = 0; i < M; i++)
	{
		cin >> a >> b >> c;
		adj[a].push_back(make_pair(b, c));
	}

	for (int i = 1; i <= 300; i++)
	{
		dp[1][i][0] = 1;
	}

	for (int i = 1; i < N; i++)
	{
		for (int j = 1; j <= 300; j++)
		{
			for (int k = 0; k <= K; k++)
			{
				if (dp[i][j][k] == 0)
				{
					continue;
				}
				for (auto it : adj[j])
				{
					int x = it.first;
					int y = it.second;
					if (k + y <= K)
					{
						dp[i + 1][x][k + y] += dp[i][j][k];
						dp[i + 1][x][y + k] %= MOD;
					}
				}
			}
		}
	}
	
	long long int res = 0;

	for (int i = 1; i <= 300; i++)
	{
		res += dp[N][i][K];
		res %= MOD;
	}

	cout << res << '\n';

	return 0;
}
0