제출 #570328

#제출 시각아이디문제언어결과실행 시간메모리
570328grt도로 폐쇄 (APIO21_roads)C++17
0 / 100
71 ms9308 KiB
#include <bits/stdc++.h> #define PB push_back #define ST first #define ND second //#pragma GCC optimize ("O3") //#pragma GCC target("tune=native") //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //using namespace __gnu_pbds; //typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; using namespace std; using ll = long long; using pi = pair<int, int>; using vi = vector<int>; const int nax = 100 * 1000 + 10; int n; vector<pi>G[nax]; bool matched[nax]; int ans; void dfs(int x, int p) { matched[x] = false; for(auto [nbh, w] : G[x]) if(nbh != p) { dfs(nbh, x); if(!matched[x] && !matched[nbh]) { matched[x] = true; ans++; } } } vector<ll> minimum_closure_costs(int N, vi U, vi V, vi W) { n = N; ll sum = 0; for(int i = 0; i < n - 1; ++i) { G[U[i]].emplace_back(V[i], W[i]); G[V[i]].emplace_back(U[i], W[i]); sum += W[i]; } dfs(0, -1); vector<ll>res(n); for(int i = 0; i < n; ++i) { res[i] = max(0LL, sum - ans*i); } return res; } //int main() { //ios_base::sync_with_stdio(0); //cin.tie(0); //cin >> n; //vi u(n-1), v(n-1), w(n-1); //for(int i = 0; i < n-1; ++i) cin >> u[i] >> v[i] >> w[i]; //auto vec = minimum_closure_costs(n, u, v, w); //for(auto x : vec) cout << x << " "; //}
#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...