Tree problem BST

Here is a problem :Problem - D - Codeforces

i read editorial and got how to do…

buut checked some solution(seg tree + RMQ):Submission #17964060 - Codeforces

can u any1 explain me this solution and suggest some problem on seg tree + RMQ