結果

問題 No.1111 コード進行
ユーザー okok
提出日時 2020-07-10 21:47:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 330 ms / 2,000 ms
コード長 1,216 bytes
コンパイル時間 1,212 ms
コンパイル使用メモリ 97,380 KB
実行使用メモリ 226,944 KB
最終ジャッジ日時 2024-04-19 16:39:34
合計ジャッジ時間 4,361 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 4 ms
6,784 KB
testcase_06 AC 7 ms
8,576 KB
testcase_07 AC 7 ms
7,680 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 5 ms
6,912 KB
testcase_10 AC 8 ms
10,240 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 8 ms
8,576 KB
testcase_13 AC 5 ms
7,168 KB
testcase_14 AC 12 ms
11,136 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 9 ms
9,216 KB
testcase_17 AC 8 ms
10,496 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 4 ms
5,376 KB
testcase_20 AC 4 ms
6,272 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 9 ms
13,056 KB
testcase_23 AC 4 ms
6,656 KB
testcase_24 AC 5 ms
7,808 KB
testcase_25 AC 14 ms
12,288 KB
testcase_26 AC 7 ms
7,936 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 92 ms
115,072 KB
testcase_29 AC 41 ms
48,768 KB
testcase_30 AC 76 ms
77,440 KB
testcase_31 AC 13 ms
16,128 KB
testcase_32 AC 84 ms
68,608 KB
testcase_33 AC 71 ms
46,464 KB
testcase_34 AC 70 ms
83,328 KB
testcase_35 AC 86 ms
105,344 KB
testcase_36 AC 212 ms
113,536 KB
testcase_37 AC 46 ms
29,440 KB
testcase_38 AC 30 ms
22,656 KB
testcase_39 AC 120 ms
76,288 KB
testcase_40 AC 179 ms
103,936 KB
testcase_41 AC 123 ms
126,848 KB
testcase_42 AC 85 ms
52,736 KB
testcase_43 AC 80 ms
46,592 KB
testcase_44 AC 28 ms
26,240 KB
testcase_45 AC 104 ms
77,696 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 330 ms
226,944 KB
testcase_48 AC 3 ms
5,376 KB
testcase_49 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

#define f first
#define s second

signed main(){
	cout<<fixed<<setprecision(10);
	
	const int MAX = 310;
	int N, M, K;
	vector<pair<pair<int,int>,int>> in;
	vector<vector<vector<int>>> dp;
	cin>>N>>M>>K;
	
	in.resize(M);
	dp.resize(N+1, vector<vector<int>>(K+1, vector<int>(MAX)));
	
	for(int i = 0; i < M; i++){
		cin>>in[i].f.f>>in[i].f.s>>in[i].s;
	}
	
	
	for(int i = 0; i < MAX; i++){
		dp[0][0][i] = 1;
	}
	
	N--;
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			for(int k = 0; k <= K; k++){
				if(in[j].s + k <= K) {
					dp[i+1][in[j].s + k][in[j].f.s] += dp[i][k][in[j].f.f];
					dp[i+1][in[j].s + k][in[j].f.s] %= MOD;
				}
				
			}
		}
	}
	
	int ans = 0;
	
	for(int i = 0; i < MAX; i++){
		ans += dp[N][K][i];
		// cout<<"i = "<<i<<" dp "<<dp[N][K][i]<<endl;
		ans %= MOD;
	}
	
	cout<<ans<<endl;
	
	return 0;
}
0