# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
966365 | eysbutno | Hard route (IZhO17_road) | C++17 | 769 ms | 175940 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.
/**
* Assume there is some hard route that goes from vertex
* u to vertex v. Let the node that the path from u to v and the
* furthest node from the hard route meet be node x. Use rerooting
* DP to calculate the hardest route and the # of such hardest routes
* for every node x.
*
* Time Complexity: O(n log(n))
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int n;
cin >> n;
vector<vector<int>> adj(n);
for (int i = 1; i < n; i++) {
int x, y;
cin >> x >> y;
--x, --y;
adj[x].push_back(y);
adj[y].push_back(x);
}
vector<int> max_length(n), path_count(n);
function<void(int, int)> dfs = [&](int u, int p) {
/**
* Calculates the longest path from vertex u,
* and the number of such paths.
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |