이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "roads.h"
using namespace std;
#define ll long long
#define ff first
#define ss second
vector<ll> minimum_closure_costs(int n, vector<int> u, vector<int> u1, vector<int> w) {
vector <pair<ll,pair<ll,ll>>> v;
ll s = 0;
for(int i = 0; i < n-1; i++){
v.push_back({w[i],{u[i],u1[i]}});
s += w[i];
}
vector <ll> p(n), p1(n), v1;
for(int i = 0; i < n; i++){
p1[u[i]]++;
p1[u1[i]]++;
}
sort(v.rbegin(), v.rend());
if(*max_element(u.begin(), u.end()) == 0){
ll s2 = s;
v1.push_back(s);
for(int i = 0; i < n-1; i++){
s2 -= (v[i].ff);
v1.push_back(s2);
}
return v1;
}
for(int i = 0; i < n; i++){
// p = p1;
p.clear();
ll s1 = s;
for(auto j : v){
if(p[j.ss.ff] < i and p[j.ss.ss] < i){
s1 -= j.ff;
p[j.ss.ff]++;
p[j.ss.ss]++;
}
}
v1.push_back(s1);
}
return v1;
}
# | 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... |