# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
515966 |
2022-01-20T08:18:01 Z |
Joo |
Journey (NOI18_journey) |
C++17 |
|
47 ms |
19712 KB |
#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 >= 500'000'001) 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;
// assert(v > i);
if(v > i)
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
0 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
544 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
0 ms |
460 KB |
Output is correct |
3 |
Correct |
0 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
544 KB |
Output is correct |
5 |
Correct |
2 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
0 ms |
460 KB |
Output is correct |
3 |
Correct |
0 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
544 KB |
Output is correct |
5 |
Correct |
2 ms |
716 KB |
Output is correct |
6 |
Correct |
1 ms |
704 KB |
Output is correct |
7 |
Correct |
45 ms |
19712 KB |
Output is correct |
8 |
Correct |
43 ms |
12240 KB |
Output is correct |
9 |
Correct |
10 ms |
1996 KB |
Output is correct |
10 |
Correct |
47 ms |
3268 KB |
Output is correct |