Problem Statement:
http://codeforces.com/contest/686/problem/D
Summary:
Given a tree of size n <= 300000, answer q <= 300000 queries of the form: find the centroid of subtree v. Centroid of subtree T is defined as a node in T such that when removed the resulting set of disjoint trees have sizes at most |T|/2 (half the size of initial subtree).
Showing posts with label Tree Traversal. Show all posts
Showing posts with label Tree Traversal. Show all posts
Sunday, July 3, 2016
Sunday, November 2, 2014
SPOJ - Another Tree Problem (MTREE)
Problem Statement:
SPOJ - Another Tree Problem (MTREE)
Summary:
Define weight of a path as the product of weights of edges in a path between node A and B in a tree, and define weight of a tree as the sum of the weight of path of all paths (inception!).
(Number of vertices \(N \leq 10^5\))
SPOJ - Another Tree Problem (MTREE)
Summary:
Define weight of a path as the product of weights of edges in a path between node A and B in a tree, and define weight of a tree as the sum of the weight of path of all paths (inception!).
(Number of vertices \(N \leq 10^5\))
Subscribe to:
Posts (Atom)