# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
961435 | zeta7532 | Road Closures (APIO21_roads) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "roads.h"
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
const ll mod = 998244353;
const ll INF = 1LL<<60;
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)
#include <vector>
std::vector<long long> minimum_closure_costs(int N, std::vector<int> U,
std::vector<int> V,
std::vector<int> W) {
vector<vector<ll>> dp(N,vector<ll>(N+1,0));
vector<vector<pair<ll,ll>>> G(N);
rep(i,N-1){
U[i]--,V[i]--;
G[U[i]].push_back({V[i],W[i]});
G[V[i]].push_back({U[i],W[i]});
}
vector<ll> ans(N,0);
rep(deg,N){
function<void(ll)> dfs=[&](ll v,ll par){
for(auto e:G[v]){
dfs(e.fi,v);
}
}
}
return ans;
}