結果

問題 No.1111 コード進行
ユーザー granddaifukugranddaifuku
提出日時 2020-07-21 12:55:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 1,059 bytes
コンパイル時間 1,547 ms
コンパイル使用メモリ 170,928 KB
実行使用メモリ 215,768 KB
最終ジャッジ日時 2023-08-27 22:20:06
合計ジャッジ時間 6,067 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,168 KB
testcase_01 AC 3 ms
5,500 KB
testcase_02 AC 3 ms
4,776 KB
testcase_03 AC 3 ms
4,800 KB
testcase_04 AC 3 ms
4,788 KB
testcase_05 AC 3 ms
5,768 KB
testcase_06 AC 5 ms
9,052 KB
testcase_07 AC 5 ms
12,640 KB
testcase_08 AC 7 ms
11,972 KB
testcase_09 AC 4 ms
6,264 KB
testcase_10 AC 6 ms
16,124 KB
testcase_11 AC 5 ms
10,460 KB
testcase_12 AC 5 ms
9,136 KB
testcase_13 AC 4 ms
8,396 KB
testcase_14 AC 7 ms
11,920 KB
testcase_15 AC 6 ms
14,704 KB
testcase_16 AC 6 ms
9,888 KB
testcase_17 AC 6 ms
16,156 KB
testcase_18 AC 5 ms
12,140 KB
testcase_19 AC 2 ms
4,800 KB
testcase_20 AC 4 ms
6,284 KB
testcase_21 AC 5 ms
13,296 KB
testcase_22 AC 5 ms
15,416 KB
testcase_23 AC 5 ms
11,228 KB
testcase_24 AC 5 ms
9,816 KB
testcase_25 AC 9 ms
16,184 KB
testcase_26 AC 7 ms
13,988 KB
testcase_27 AC 3 ms
5,508 KB
testcase_28 AC 37 ms
130,108 KB
testcase_29 AC 36 ms
124,456 KB
testcase_30 AC 31 ms
86,288 KB
testcase_31 AC 8 ms
20,348 KB
testcase_32 AC 72 ms
162,644 KB
testcase_33 AC 33 ms
55,768 KB
testcase_34 AC 30 ms
109,528 KB
testcase_35 AC 54 ms
190,460 KB
testcase_36 AC 78 ms
131,508 KB
testcase_37 AC 78 ms
121,592 KB
testcase_38 AC 57 ms
87,616 KB
testcase_39 AC 47 ms
81,952 KB
testcase_40 AC 72 ms
138,588 KB
testcase_41 AC 44 ms
152,708 KB
testcase_42 AC 75 ms
130,292 KB
testcase_43 AC 52 ms
84,224 KB
testcase_44 AC 32 ms
75,580 KB
testcase_45 AC 49 ms
127,940 KB
testcase_46 AC 133 ms
215,768 KB
testcase_47 AC 134 ms
215,768 KB
testcase_48 AC 151 ms
215,716 KB
testcase_49 AC 150 ms
215,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int N = 301;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, m, K;
	cin >> n >> m >> K;
	vector<pair<int, int> > code[N];
	ll dp[n][N][N] = {};
	rep(i, N) dp[0][i][0] = 1;
	rep(i, m) {
	  int p, q, c;
	  cin >> p >> q >> c;
	  code[p - 1].emplace_back(q - 1, c);
	}
	rep(i, n - 1) {
	  rep(j, N) {
		if (code[j].size() == 0) continue;
		rep(k, N) {
		  rep(l, code[j].size()) {
			int next = code[j][l].first, comp = code[j][l].second;
			if (k + comp >= N) continue;
			dp[i + 1][next][k + comp] += dp[i][j][k];
			dp[i + 1][next][k + comp] %= MOD;
		  }
		}
	  }
	}
	ll res = 0;
	rep(i, N) {
	  res += dp[n - 1][i][K];
	  res %= MOD;
	}
	cout << res << endl;
	
    return 0;
}

0