結果
| 問題 |
No.1111 コード進行
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-07-21 12:55:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 173 ms / 2,000 ms |
| コード長 | 1,059 bytes |
| コンパイル時間 | 2,641 ms |
| コンパイル使用メモリ | 171,544 KB |
| 実行使用メモリ | 215,808 KB |
| 最終ジャッジ日時 | 2024-12-28 07:06:32 |
| 合計ジャッジ時間 | 4,895 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 48 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)
using ll = long long;
using ld = long double;
const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int N = 301;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(0);
int n, m, K;
cin >> n >> m >> K;
vector<pair<int, int> > code[N];
ll dp[n][N][N] = {};
rep(i, N) dp[0][i][0] = 1;
rep(i, m) {
int p, q, c;
cin >> p >> q >> c;
code[p - 1].emplace_back(q - 1, c);
}
rep(i, n - 1) {
rep(j, N) {
if (code[j].size() == 0) continue;
rep(k, N) {
rep(l, code[j].size()) {
int next = code[j][l].first, comp = code[j][l].second;
if (k + comp >= N) continue;
dp[i + 1][next][k + comp] += dp[i][j][k];
dp[i + 1][next][k + comp] %= MOD;
}
}
}
}
ll res = 0;
rep(i, N) {
res += dp[n - 1][i][K];
res %= MOD;
}
cout << res << endl;
return 0;
}