# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
934776 | eysbutno | Hard route (IZhO17_road) | C++17 | 613 ms | 132180 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;
using ll = long long;
using pii = pair<int, int>;
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()
#define f first
#define s second
template<class T> bool smin(T& a, T b) {
return b < a ? a = b, 1 : 0;
}
template<class T> bool smax(T& a, T b) {
return b > a ? a = b, 1 : 0;
}
int main() {
cin.tie(0) -> sync_with_stdio(0);
int n; cin >> n;
vector adj(n, vector<int>());
for (int i = 1; i < n; i++) {
int x, y; cin >> x >> y;
adj[--x].push_back(--y);
adj[y].push_back(x);
}
vector<int> d(n), c(n);
auto dfs = [&](int u, int p, auto&& dfs) -> void {
d[u] = 0, c[u] = 1;
for (int v : adj[u]) if (v != p) {
dfs(v, u, dfs);
if (smax(d[u], d[v] + 1)) {
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |