# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
388906 | saarang123 | Factories (JOI14_factories) | C++17 | 6061 ms | 171004 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 <bits/stdc++.h>
#ifndef saarang
#include "factories.h"
#endif
using namespace std;
const int mxn = 500 * 1000 + 3, lgn = 21;
vector<array<int, 2>> g[mxn];
int sz[mxn], par[mxn], dt[mxn], lvl[mxn];
long long d[mxn], ans[mxn], dist[lgn][mxn];
bool cent[mxn];
int n, m, cnt;
int dfssz(int v, int p = -1) {
sz[v] = 1;
for(auto &[u, w] : g[v]) if(u != p && !cent[u])
sz[v] += dfssz(u, v);
return sz[v];
}
int fcent(int v, int p = -1) {
for(auto &[u, w] : g[v]) if(u != p && !cent[u])
if(sz[u] > cnt / 2)
return fcent(u, v);
return v;
}
void fdist(int v, int p, int l) {
for(auto &[u, w] : g[v]) if(u != p && !cent[u]) {
dist[l][u] = dist[l][v] + w;
fdist(u, v, l);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |