What is this dp definition and why child is added , although adding dp[child]
Why is child added here and what does this dp represent
This is the way to calculate the answer only. sz[i] is the size of total subtree, for total ans you need the ans of child where child was the root itself plus when child acts simply as a child, so you add it’s subtree size .
Try to calculate the answer by yourself and you’ll see how it’s correct.
The question link https://codeforces.com/problemset/problem/1187/E
thinking brodly , the value in dp[child] already stores the sz[child] component , so why we are adding it . I mean if i want to calculate the value of root , then it’s child dp values are sufficient but this dp is calculating total answer considering the root , so how adding child size is resulting in the total answer by taking that node as the root !!
Accha sir ,One question , What Sanyam sir teaches , vo kise bhi bacche ko samaj aata hai ?? literally his 70% explanation videos are so vague that poore dimaag ka bharta ban jaata hai !! I am not saying for this video , this video has faaaaar better explanation than his other videos . His other videos are like …
no child adds twice to the answer, so size[child] has to be added twice
I haven’t seen much but if you try to figure out the solution yourself for atlease 30 mins, and then if you fail , then his videos would definitely make sense
