이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "roads.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli long long int
#define debugsl(a) cout << #a << " = " << a << ", "
#define debug(a) cout << #a << " = " << a << endl
#define MAX 100000
#define des first
#define peso second
vector< pair<lli,lli> > hijos[MAX+2];
lli dp[MAX+2][2];
std::vector <long long> minimum_closure_costs(int N, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
vector<long long> res (N, 0);
rep(i,0,N-2) {
hijos[ U[i] ].push_back({V[i], W[i]});
hijos[ V[i] ].push_back({U[i], W[i]});
}
rep(i,1,N-1) {
for (auto h : hijos[i]) if (h.des == i-1) {
dp[i][1] = dp[i-1][0];
dp[i][0] = min(dp[i-1][0], dp[i-1][1]);
dp[i][0] += h.peso;
res[0] += h.peso;
}
}
res[1] = min(dp[N-1][0], dp[N-1][1]);
return res;
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |