# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
230667 | arbor | Factories (JOI14_factories) | C++14 | 5332 ms | 148364 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>
#define all(x) x.begin(), x.end()
#define lc (i << 1)
#define rc (i << 1 | 1)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MN = 5e5 + 5, LN = 17, MOD = 1e9 + 7, INF = 0x3f3f3f3f, BSZ = 320;
vector<pii> g[MN];
int sz[MN], par[MN], dep[MN], qid[MN], id = 1;
ll dis[20][MN], dp[MN];
bool vis[MN];
int get_sz(int u, int p) {
sz[u] = 1;
for (pii e : g[u]) if (e.first != p && !vis[e.first])
sz[u] += get_sz(e.first, u);
return sz[u];
}
int centroid(int u, int p, int s) {
for (pii e : g[u]) if (e.first != p && !vis[e.first] && sz[e.first] > s / 2)
return centroid(e.first, u, s);
return u;
}
void dfs(int u, int p, ll d, int lvl) {
dis[lvl][u] = d;
for (pii e : g[u]) if (e.first != p && !vis[e.first])
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |