이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vvi vector<vi>
#define vll vector<ll>
using namespace std;
const int mxn=1e5+5;
vector<pii>g[mxn];int d[mxn]{0};
struct node{
ll tt;int cr;
node *l,*r;
node(int x,int y) : tt(x),cr(y),l(NULL),r(NULL){};
node(node *l,node *r) : tt(l->tt+r->tt),cr(l->cr+r->cr),l(l),r(r){};
};
node*rt[mxn];
node* upd(node*t,ll l,ll r,ll val){
if(!t)t=new node(0,0);
if(!t->l)t->l=new node(0,0);
if(!t->r)t->r=new node(0,0);
if(l==r)return new node(t->tt+val,t->cr+1);
ll m=(l+r)>>1;
if(val<=m)return new node(upd(t->l,l,m,val),t->r);
else return new node(t->l,upd(t->r,m+1,r,val));
}
vll minimum_closure_costs(int N,vi U,vi V,vi W){vll ans(N,0);
for(int i=0;i<N-1;i++)g[U[i]].pb({V[i],W[i]}),g[V[i]].pb({U[i],W[i]});
for(int i=0;i<N;i++)for(auto v:g[i])rt[i]=upd(rt[i],-1e14,1e14,-v.s);
return ans;
}
# | 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... |