結果

問題 No.1111 コード進行
ユーザー cn_449cn_449
提出日時 2020-07-10 21:37:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,786 bytes
コンパイル時間 1,184 ms
コンパイル使用メモリ 115,640 KB
実行使用メモリ 221,952 KB
最終ジャッジ日時 2024-04-19 16:13:48
合計ジャッジ時間 3,721 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 5 ms
5,504 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 5 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 6 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 5 ms
6,016 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 6 ms
5,888 KB
testcase_23 AC 5 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 7 ms
7,424 KB
testcase_26 AC 6 ms
5,504 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 6 ms
7,168 KB
testcase_29 AC 16 ms
17,408 KB
testcase_30 AC 18 ms
13,184 KB
testcase_31 AC 4 ms
5,376 KB
testcase_32 AC 34 ms
18,560 KB
testcase_33 AC 29 ms
12,672 KB
testcase_34 AC 6 ms
6,912 KB
testcase_35 AC 11 ms
9,856 KB
testcase_36 AC 73 ms
107,904 KB
testcase_37 AC 50 ms
89,472 KB
testcase_38 AC 37 ms
45,312 KB
testcase_39 AC 49 ms
26,496 KB
testcase_40 AC 65 ms
85,632 KB
testcase_41 AC 29 ms
26,496 KB
testcase_42 AC 56 ms
96,128 KB
testcase_43 AC 43 ms
54,528 KB
testcase_44 AC 23 ms
31,488 KB
testcase_45 AC 41 ms
49,792 KB
testcase_46 AC 36 ms
19,200 KB
testcase_47 AC 120 ms
19,840 KB
testcase_48 AC 111 ms
221,952 KB
testcase_49 AC 95 ms
163,200 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, 300) dp[0][i][0] = 1;
	rep(i, n - 1) {
		rep(j, m) {
			rep(x, 300) {
				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, 300) ans += dp[n - 1][i][k];
	cout << ans % mod << '\n';
}
0