結果

問題 No.1111 コード進行
ユーザー cn_449cn_449
提出日時 2020-07-10 21:39:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 1,786 bytes
コンパイル時間 1,075 ms
コンパイル使用メモリ 112,296 KB
実行使用メモリ 224,120 KB
最終ジャッジ日時 2023-08-01 17:07:47
合計ジャッジ時間 4,008 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,172 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,384 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 3 ms
6,224 KB
testcase_06 AC 4 ms
8,412 KB
testcase_07 AC 4 ms
12,588 KB
testcase_08 AC 5 ms
12,492 KB
testcase_09 AC 3 ms
6,352 KB
testcase_10 AC 6 ms
16,408 KB
testcase_11 AC 4 ms
10,376 KB
testcase_12 AC 4 ms
8,536 KB
testcase_13 AC 4 ms
8,360 KB
testcase_14 AC 5 ms
12,444 KB
testcase_15 AC 4 ms
14,448 KB
testcase_16 AC 5 ms
10,648 KB
testcase_17 AC 5 ms
16,488 KB
testcase_18 AC 3 ms
8,240 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 2 ms
6,288 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 5 ms
16,624 KB
testcase_23 AC 4 ms
12,492 KB
testcase_24 AC 4 ms
10,392 KB
testcase_25 AC 7 ms
16,736 KB
testcase_26 AC 6 ms
14,756 KB
testcase_27 AC 3 ms
6,524 KB
testcase_28 AC 19 ms
73,196 KB
testcase_29 AC 23 ms
77,864 KB
testcase_30 AC 25 ms
73,780 KB
testcase_31 AC 6 ms
20,648 KB
testcase_32 AC 41 ms
80,376 KB
testcase_33 AC 33 ms
59,796 KB
testcase_34 AC 18 ms
73,012 KB
testcase_35 AC 22 ms
75,304 KB
testcase_36 AC 89 ms
123,748 KB
testcase_37 AC 59 ms
110,664 KB
testcase_38 AC 36 ms
81,520 KB
testcase_39 AC 47 ms
75,808 KB
testcase_40 AC 76 ms
114,808 KB
testcase_41 AC 32 ms
84,372 KB
testcase_42 AC 70 ms
117,124 KB
testcase_43 AC 44 ms
82,072 KB
testcase_44 AC 22 ms
74,936 KB
testcase_45 AC 43 ms
93,844 KB
testcase_46 AC 43 ms
82,208 KB
testcase_47 AC 129 ms
90,440 KB
testcase_48 AC 126 ms
224,120 KB
testcase_49 AC 110 ms
185,372 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