# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
126117 | EntityIT | Unique Cities (JOI19_ho_t5) | C++14 | 1081 ms | 54036 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;
#define fi first
#define se second
#define pb push_back
const int N = (int)2e5 + 5, M = N;
int n, m, c[N], diameterTip[2], depth[N], ans[N], cnt[M], curAns, mx[N][2];
pair<int, bool> group[N];
set< pair<int, int> > valid, path;
vector<int> gr[N];
void dfs (int u, int p) {
depth[u] = depth[p] + 1;
for (int v : gr[u]) if (v != p) {
dfs(v, u);
}
}
void prep (int u, int p) {
depth[u] = depth[p] + 1;
mx[u][0] = mx[u][1] = 0;
for (int v : gr[u]) if (v != p) {
prep(v, u);
int tmp = mx[v][0];
for (int _ = 0; _ < 2; ++_) if (mx[u][_] < tmp) swap(tmp, mx[u][_]);
}
mx[u][0] = max(mx[u][0], depth[u]);
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |