結果
| 問題 |
No.1111 コード進行
|
| コンテスト | |
| ユーザー |
ぷら
|
| 提出日時 | 2021-03-14 19:46:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 324 ms / 2,000 ms |
| コード長 | 949 bytes |
| コンパイル時間 | 1,626 ms |
| コンパイル使用メモリ | 173,900 KB |
| 実行使用メモリ | 219,248 KB |
| 最終ジャッジ日時 | 2024-11-06 08:50:36 |
| 合計ジャッジ時間 | 5,713 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 48 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
long long dp[305][305][305];
int main() {
int N,M,K;
cin >> N >> M >> K;
vector<vector<pair<int,int>>>road(300);
for(int i = 0; i < M; i++) {
int P,Q,C;
cin >> P >> Q >> C;
P--;
Q--;
road[P].push_back({Q,C});
}
for(int i = 0; i < 300; i++) {
dp[0][i][0] = 1;
}
for(int i = 0; i < N-1; i++) {
for(int j = 0; j < 300; j++) {
for(int k = 0; k <= 300; k++) {
for(auto l:road[j]) {
if(k+l.second <= 300) {
dp[i+1][l.first][k+l.second] += dp[i][j][k];
dp[i+1][l.first][k+l.second] %= mod;
}
}
}
}
}
long long ans = 0;
for(int i = 0; i < 300; i++) {
ans += dp[N-1][i][K];
ans %= mod;
}
cout << ans << endl;
}
ぷら