結果
| 問題 |
No.1111 コード進行
|
| コンテスト | |
| ユーザー |
nrvft
|
| 提出日時 | 2020-07-10 21:48:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 236 ms / 2,000 ms |
| コード長 | 1,975 bytes |
| コンパイル時間 | 2,041 ms |
| コンパイル使用メモリ | 198,136 KB |
| 最終ジャッジ日時 | 2025-01-11 18:18:14 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 48 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)
template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif
const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll dp[305][305][305];
int main() {
init();
ll N, M, K;
cin >> N >> M >> K;
vvc<pair<ll, ll>> G(300);
rep(i, M){
ll p, q, c;
cin >> p >> q >> c;
p--, q--;
G[p].eb(q, c);
}
rep(i, 300) dp[0][i][0] = 1;
rep(i, N - 1){
rep(j, 300){
repa(p, G[j]){
auto [to, c] = p;
rep(k, K+1){
if (k + c <= K) (dp[i + 1][to][k + c] += dp[i][j][k]) %= MOD;
}
}
}
}
ll ans = 0;
rep(i, 300)(ans += dp[N - 1][i][K]) %= MOD;
cout << ans << endl;
}
nrvft