# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
422555 | juggernaut | Factories (JOI14_factories) | C++17 | 4643 ms | 138828 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.
#pragma GCC optimize("Ofast")
#include"factories.h"
#include<bits/stdc++.h>
#ifndef EVAL
#include"grader.cpp"
#endif
template<class T>void umin(T &a,T b){if(b<a)a=b;}
using namespace std;
typedef long long ll;
vector<pair<int,int>>g[500001];
int sz[500001];
bool black[500001];
void build_sz(int v,int p){
sz[v]=1;
for(auto &[to,wegiht]:g[v])if(to!=p&&!black[to]){
build_sz(to,v);
sz[v]+=sz[to];
}
}
int get_centroid(int v,int p){
int siz=sz[v]>>1;
while(true){
bool can=true;
for(auto &[to,weight]:g[v]){
if(black[to]||to==p)continue;
if(sz[to]>siz){
can=false;
p=v;
v=to;
break;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |