Could someone help me understand and solve SPOJ QTREE4. I've solved QTREE13 using HLD and Segment trees but the same approach doesn't seem to work in this one. Since, we need to find the longest shortest distance between any two white nodes in a tree usual segment tree methods aren't working for me. Can centroid decomposition be used in this question? If yes could someone please explain me how. I couldn't find any good resources for the same apart from this link http://codeforces.com/blog/entry/10533 asked 26 Jun '14, 22:48

This link: https://www.quora.com/WhatistheapproachtosolvetheSPOJproblemQTREE4 describes a nice solution using Centroid Decomposition, although more tough to implement than SPOJ QTREE 13. answered 05 Mar '18, 22:25
