結果

問題 No.1111 コード進行
ユーザー 沙耶花沙耶花
提出日時 2020-07-10 21:36:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 882 bytes
コンパイル時間 2,791 ms
コンパイル使用メモリ 208,160 KB
実行使用メモリ 112,640 KB
最終ジャッジ日時 2024-04-19 16:06:06
合計ジャッジ時間 5,262 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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
5,376 KB
testcase_06 AC 5 ms
5,504 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 5 ms
6,784 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 4 ms
5,504 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 6 ms
6,912 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 5 ms
6,016 KB
testcase_17 AC 5 ms
6,656 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 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
7,808 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 8 ms
7,552 KB
testcase_26 AC 5 ms
5,504 KB
testcase_27 AC 3 ms
5,376 KB
testcase_28 AC 57 ms
58,368 KB
testcase_29 AC 32 ms
27,008 KB
testcase_30 AC 54 ms
39,424 KB
testcase_31 AC 8 ms
9,344 KB
testcase_32 AC 53 ms
36,480 KB
testcase_33 AC 40 ms
24,448 KB
testcase_34 AC 42 ms
42,624 KB
testcase_35 AC 56 ms
54,784 KB
testcase_36 AC 56 ms
57,344 KB
testcase_37 AC 20 ms
17,920 KB
testcase_38 AC 21 ms
13,568 KB
testcase_39 AC 65 ms
39,296 KB
testcase_40 AC 77 ms
53,120 KB
testcase_41 AC 64 ms
64,384 KB
testcase_42 AC 33 ms
29,056 KB
testcase_43 AC 42 ms
25,216 KB
testcase_44 AC 16 ms
15,104 KB
testcase_45 AC 41 ms
40,320 KB
testcase_46 AC 10 ms
8,448 KB
testcase_47 AC 110 ms
112,640 KB
testcase_48 AC 11 ms
8,448 KB
testcase_49 AC 10 ms
8,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int N,M,K;
	cin>>N>>M>>K;
	
	vector<vector<pair<int,int>>> E(300,vector<pair<int,int>>());
	for(int i=0;i<M;i++){
		int u,v,c;
		cin>>u>>v>>c;
		E[u-1].emplace_back(v-1,c);
	}
	
	vector<vector<vector<int>>> dp(N,vector<vector<int>>(300,vector<int>(K+1,0)));
	for(int i=0;i<300;i++)dp[0][i][0] = 1;
	
	for(int i=0;i<N-1;i++){
		for(int j=0;j<300;j++){
			for(int k=0;k<=K;k++){
				if(dp[i][j][k]==0)continue;
				for(int a=0;a<E[j].size();a++){
					int nj = E[j][a].first;
					int nk = k+E[j][a].second;
					if(nk>K)continue;
					dp[i+1][nj][nk] = mod(dp[i+1][nj][nk] + dp[i][j][k]);
				}
			}
		}
	}
	

	
	int ans = 0;
	for(int i=0;i<300;i++)ans = mod(ans + dp.back()[i][K]);
	cout<<ans<<endl;
	
	return 0;
}
0