# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1046534 | Turkhuu | Factories (JOI14_factories) | C++17 | 2281 ms | 196760 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;
using ll = long long;
int N;
vector<vector<pair<int, int>>> adj;
vector<vector<int>> s;
vector<int> dep, euler, pos, lg, sz, par, vis;
vector<ll> d2r, best;
void dfs(int x, int p) {
pos[x] = euler.size();
euler.push_back(x);
for (auto [y, z] : adj[x]) {
if (y == p) continue;
dep[y] = dep[x] + 1;
d2r[y] = d2r[x] + z;
dfs(y, x);
euler.push_back(x);
}
}
int f(int i, int j) {
return (i != -1 && (j == -1 || dep[i] < dep[j])) ? i : j;
}
void build() {
int n = euler.size();
s.resize(lg[n] + 1);
s[0] = euler;
for (int i = 0; i < lg[n]; i++) {
s[i + 1].resize(n - (2 << i) + 1);
for (int j = 0; j + (2 << i) <= n; j++) {
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |