Submission #384177

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
3841772021-03-31 16:15:07Aryan_RainaFactories (JOI14_factories)C++14
100 / 100
6464 ms191508 KiB
#include "factories.h"
#include <bits/stdc++.h>
using namespace std;
#define ar array
#define ll long long
const int MXN = 5e5+9, LGN = 20;
const ll INF = 1e17;
ll n, sz[MXN], lvl[MXN], par[MXN], dist[LGN][MXN];
bool dead[MXN];
vector<ar<ll,2>> g[MXN];
vector<ll> d(MXN, INF);
void get_sz(int u, int pu) {
sz[u] = 1;
for (auto v : g[u]) if (v[1] != pu && !dead[v[1]]) {
get_sz(v[1], u);
sz[u] += sz[v[1]];
}
}
int centroid(int u, int pu, int rt) {
for (auto v : g[u]) if (v[1] != pu && !dead[v[1]]) {
if (sz[v[1]] > sz[rt]/2) return centroid(v[1], u, rt);
}
return u;
}
int OneCentroid (int rt) { get_sz(rt, rt); return centroid(rt, rt, rt); }
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...