Submission #425864

#TimeUsernameProblemLanguageResultExecution timeMemory
425864OzyRoad Closures (APIO21_roads)C++17
7 / 100
72 ms14228 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...