#include <bits/stdc++.h>
using namespace std;
const int N = 1e4+10;
int n, M, H, dp[N][410];
vector<pair<int, int>> G[N];
inline void add(int &a, int b){
if(a + b >= 500000001) a = 500000001;
else a += b;
}
int main(void){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> M >> H;
for(int i = 0; i < n-1; i++){
for(int j = 0; j < H; j++){
int v, mn; cin >> v >> mn;
G[i].emplace_back(v, mn);
}
}
dp[0][0] = 1;
for(int u = 0; u < n-1; u++){
for(int m = 1; m < M; m++){
add(dp[u][m], dp[u][m-1]);
}
for(auto [v, mn] : G[u]){
for(int m = 0; m+mn < M; m++){
add(dp[v][m+mn], dp[u][m]);
}
}
}
for(int m = 0; m < M; m++) cout << dp[n-1][m] << " ";
cout << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
0 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
0 ms |
460 KB |
Output is correct |
3 |
Incorrect |
1 ms |
588 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
0 ms |
460 KB |
Output is correct |
3 |
Incorrect |
1 ms |
588 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |