# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
780235 | cheat_when_I_was_young | Factories (JOI14_factories) | C++17 | 5029 ms | 281412 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 "factories.h"
#include "bits/stdc++.h"
using namespace std;
const int NM = 5e5 + 5;
const int LG = __lg(NM<<1) + 1;
int in[NM], h[NM], color[NM], par[NM];
long long d[NM], dp[NM][3], ans;
pair<int,int> ST[LG][NM<<1];
vector<int> tour, newAdj[NM];
vector<pair<int,int>> adj[NM];
void dfs(int u, int par) {
in[u] = tour.size();
tour.push_back(u);
for (auto &vv: adj[u]) {
int v = vv.first, w = vv.second;
if (v == par) continue;
d[v] = d[u] + w;
h[v] = h[u] + 1;
dfs(v, u);
tour.push_back(u);
}
}
void build() {
for (int i = 0; i < (int)tour.size(); ++i)
ST[0][i] = {h[tour[i]], tour[i]};
for (int j = 1; j < LG; ++j)
for (int i = 0; i + (1<<j) - 1 < (int)tour.size(); ++i)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |