# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
586441 | M_W | Journey (NOI18_journey) | C++17 | 1 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ii pair<int, int>
using namespace std;
const int md = 500000001;
vector<ii> adj[505];
int dp[505][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);
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 ", dp[N][i]);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |