Problem — Minimum Ugliness Appeared in Wednesday Contest on CodeChef.
My Solution — https://www.codechef.com/viewsolution/96669203
Approach (Using Binary Uplifting) →
- (Precomputing) Binary Uplifting using DFS.
- For Each query, identifying one node of longest diameter from given set
- Calculating distance from above node to all nodes present in set, answer is (maximum distance / 2).
It is failing on 4/8 testcases.
Used This: Binary lifting: Binary Lifting (CP Algorithm), Diameter of Tree & Application: 101271