Codechef problems

https://www.codechef.com/SPGC2021/problems/SOPC21D

What should be the apraoch and impementation for this

Concept of trees are required to solve this problems. I would suggest you to wait for it’s editorial as well as video solution. Codechef will upload both of them within a week. You can take reference from it.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

the editorial is not available yet can u please help