# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
966365 | eysbutno | Hard route (IZhO17_road) | C++17 | 769 ms | 175940 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* 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... |