結果

問題 No.1111 コード進行
ユーザー batasanblogbatasanblog
提出日時 2023-04-07 08:19:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 419 ms / 2,000 ms
コード長 1,559 bytes
コンパイル時間 4,031 ms
コンパイル使用メモリ 263,920 KB
実行使用メモリ 223,488 KB
最終ジャッジ日時 2024-04-10 16:11:32
合計ジャッジ時間 9,338 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,552 KB
testcase_01 AC 4 ms
7,040 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 4 ms
6,944 KB
testcase_04 AC 4 ms
6,940 KB
testcase_05 AC 6 ms
7,040 KB
testcase_06 AC 12 ms
10,496 KB
testcase_07 AC 14 ms
14,336 KB
testcase_08 AC 10 ms
13,440 KB
testcase_09 AC 8 ms
7,552 KB
testcase_10 AC 18 ms
17,792 KB
testcase_11 AC 8 ms
12,160 KB
testcase_12 AC 11 ms
10,496 KB
testcase_13 AC 8 ms
9,728 KB
testcase_14 AC 17 ms
13,440 KB
testcase_15 AC 12 ms
16,384 KB
testcase_16 AC 13 ms
11,264 KB
testcase_17 AC 16 ms
17,920 KB
testcase_18 AC 9 ms
13,440 KB
testcase_19 AC 4 ms
6,940 KB
testcase_20 AC 5 ms
7,680 KB
testcase_21 AC 9 ms
14,848 KB
testcase_22 AC 19 ms
17,024 KB
testcase_23 AC 10 ms
12,800 KB
testcase_24 AC 9 ms
11,392 KB
testcase_25 AC 25 ms
17,920 KB
testcase_26 AC 14 ms
15,744 KB
testcase_27 AC 5 ms
7,040 KB
testcase_28 AC 188 ms
135,296 KB
testcase_29 AC 137 ms
129,408 KB
testcase_30 AC 141 ms
89,984 KB
testcase_31 AC 24 ms
22,400 KB
testcase_32 AC 214 ms
168,832 KB
testcase_33 AC 111 ms
58,752 KB
testcase_34 AC 149 ms
114,048 KB
testcase_35 AC 245 ms
197,120 KB
testcase_36 AC 232 ms
136,704 KB
testcase_37 AC 130 ms
126,592 KB
testcase_38 AC 98 ms
91,520 KB
testcase_39 AC 175 ms
85,632 KB
testcase_40 AC 235 ms
143,872 KB
testcase_41 AC 225 ms
158,592 KB
testcase_42 AC 175 ms
135,296 KB
testcase_43 AC 128 ms
87,936 KB
testcase_44 AC 84 ms
79,104 KB
testcase_45 AC 173 ms
133,120 KB
testcase_46 AC 198 ms
223,360 KB
testcase_47 AC 419 ms
223,488 KB
testcase_48 AC 185 ms
223,488 KB
testcase_49 AC 183 ms
223,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
//using mint = static_modint<998244353>;
//using mint = modint;
using mint = static_modint<1000000007>;
using vm = vector<mint>;
using vvm = vector<vm>;
using vvvm = vector<vvm>;
ostream &operator<<(ostream &o,const mint &m){cout<<m.val();return o;}
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll,ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);++i)
#define reps(i,s,n) for(ll i=(s);i<(ll)(n);++i)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);++i)
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const long long INF = 1e18;

#ifdef DEBUG
#include <debug.hpp>
#endif

int main(){
#ifdef DEBUG
	cout << "--- Input ---" << endl;
#endif
	ll N,M,K;cin>>N>>M>>K;
	vector<vector<pl>> E(301);
	rep(i,M){
		ll a,b,c;cin>>a>>b>>c;
		//E.at(a).at(i)=make_pair(b,c);
		E.at(a).push_back({b,c});
	}
	reps(i,1,301)E.at(0).push_back({i,0});
#ifdef DEBUG
	cout << "--- Logic ---" << endl;
#endif
	vvvm dp(N+1,vvm(602,vm(301)));
	dp.at(0).at(0).at(0)=1;
	rep(i,N)rep(k,K+1)rep(lst,301){
		for(auto &p:E.at(lst)){
			assert(i+1>=0&&i+1<dp.size());
			assert(k+p.second>=0&&k+p.second<dp.at(i+1).size());
			assert(p.first>=0&&p.first<dp.at(i+1).at(k+p.second).size());
			dp.at(i+1).at(k+p.second).at(p.first)
				+=dp.at(i).at(k).at(lst);
		}
	}
#ifdef DEBUG
	//cout<<dp;
	cout << "--- Answer ---" << endl;
#endif
	mint ans=0;
	reps(lst,1,301)ans+=dp.at(N).at(K).at(lst);
	cout<<ans<<endl;

	return 0;
}
//cout << fixed << setprecision(9);
0