# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1160028 | nhphuc | Factories (JOI14_factories) | C++17 | 12 ms | 18240 KiB |
#include <bits/stdc++.h>
#include "factories.h"
using namespace std;
const int N = 500500;
const long long inf = 1e18;
int sub[N], pos[N];
long long dis[N], mn[N];
pair<int, long long> par[N];
vector<int> modify;
vector<pair<int, int>> adj[N];
void dfs (int u, int p = 0, long long dep = 0){
sub[u] = 1;
dis[u] = dep;
for (auto [v, d] : adj[u]){
if (v != p && pos[v] == 0){
dfs(v, u, dep + 1ll * d);
sub[u] += sub[v];
}
}
}
int centroid (int u, int p, int n){
for (auto [v, d] : adj[u]){
if (v != p && pos[v] == 0 && sub[v] * 2 > n){
return centroid(v, u, n);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |