# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
157154 | fedoseevtimofey | Construction of Highway (JOI18_construction) | C++14 | 2071 ms | 111180 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>
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 7;
vector <int> g[N];
int sz[N], st[N], en[N], par[N], in[N], out[N], h[N];
int A[N], B[N], C[N];
deque <pair <int, int>> col[N];
void dfs(int u = 0, int p = -1) {
par[u] = p;
for (int i = 0; i < g[u].size(); ++i) {
if (g[u][i] == p) {
g[u].erase(g[u].begin() + i);
break;
}
}
sz[u] = 1;
for (int v : g[u]) {
dfs(v, u);
sz[u] += sz[v];
}
for (int i = 1; i < (int)g[u].size(); ++i) {
if (sz[g[u][i]] > sz[g[u][0]]) swap(g[u][i], g[u][0]);
}
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... |