# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
586457 |
2022-06-30T09:43:32 Z |
M_W |
Journey (NOI18_journey) |
C++17 |
|
168 ms |
23460 KB |
#include <bits/stdc++.h>
#define ii pair<int, int>
using namespace std;
const int md = 500000001;
vector<ii> adj[10001];
int dp[10001][505];
int main(){
int N, M, H;
scanf("%d %d %d", &N, &M, &H);
for(int i = 1; i < N; i++){
for(int j = 1, u, w; j <= H; j++){
scanf("%d %d", &u, &w);
if(u + 1 > i) adj[i].push_back({u + 1, w});
}
}
for(auto [x, w] : adj[1]) dp[x][min(501, w)]++;
for(int i = 2; i <= N; i++){
for(int j = 0; j < M; j++){
if(j > 0) dp[i][j] = min(dp[i][j] + dp[i][j - 1], md);
for(auto [x, w] : adj[i]){
dp[x][min(501, j + w)] += dp[i][j];
dp[x][min(501, j + w)] = min(dp[x][min(501, j + w)], md);
}
// printf(">> %d %d : %d\n", i, j, dp[i][j]);
}
}
for(int i = 0; i < M; i++) printf("%d ", min(dp[N][i], md));
}
Compilation message
journey.cpp: In function 'int main()':
journey.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
9 | scanf("%d %d %d", &N, &M, &H);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
journey.cpp:12:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | scanf("%d %d", &u, &w);
| ~~~~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
684 KB |
Output is correct |
6 |
Correct |
2 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
684 KB |
Output is correct |
6 |
Correct |
2 ms |
724 KB |
Output is correct |
7 |
Correct |
75 ms |
23460 KB |
Output is correct |
8 |
Correct |
94 ms |
14460 KB |
Output is correct |
9 |
Correct |
28 ms |
2272 KB |
Output is correct |
10 |
Correct |
168 ms |
3448 KB |
Output is correct |