Update: The problem was my 'decompose' function. Its return type was 'int' though I didn't return anything, so I changed it into 'void' and I got AC. Weird but worked.
I tried to solve this problem using HLD and Segment Tree. I didn't find LCA explicitly rather used HLD.
Code: https://pastebin.ubuntu.com/p/BfxMZH9hz3/
This solution gives runtime error. I can't find any reason for this kind of verdict.
I have already read this blog but couldn't understand why my code isn't working.
Can anyone help me?