結果
| 問題 |
No.1111 コード進行
|
| コンテスト | |
| ユーザー |
batasanblog
|
| 提出日時 | 2023-04-07 08:19:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 436 ms / 2,000 ms |
| コード長 | 1,559 bytes |
| コンパイル時間 | 3,938 ms |
| コンパイル使用メモリ | 259,864 KB |
| 最終ジャッジ日時 | 2025-02-11 23:34:51 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 48 |
ソースコード
#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);
batasanblog