結果

問題 No.1111 コード進行
ユーザー tktk_snsn
提出日時 2021-03-18 19:59:55
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 791 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 73,396 KB
実行使用メモリ 215,728 KB
最終ジャッジ日時 2024-11-17 01:52:02
合計ジャッジ時間 3,208 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 39 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
using namespace std;
using ll = long long;
const ll mod = 1000000009;
ll dp[301][301][301];

struct edge
{
int to;
ll cost;
edge(int to, ll cost):to(to), cost(cost) {}
};


int main()
{
int n, m, k;
cin >> n >> m >> k;
vector<vector<edge>> G(300);
for (int i = 0; i < m; ++i)
{
int p, q;
ll c;
cin >> p >> q >> c;
p--; q--;
G[p].push_back(edge(q, c));
}
for (int i = 0; i < 300; ++i) dp[0][i][0] = 1;
for (int i = 0; i < n - 1; ++i)
{
for (int s = 0; s < 300; ++s)
{
for (int j = 0; j < k + 1; ++j)
{
for (edge& e : G[s])
{
if (j + e.cost <= k)
{
dp[i + 1][e.to][j + e.cost] += dp[i][s][j];
dp[i + 1][e.to][j + e.cost] %= mod;
}
}
}
}
}
ll ans = 0;
for (int i = 0; i < 300; ++i) {
ans += dp[n - 1][i][k];
ans %= mod;
}
cout << ans << endl;
return 0;
}

0