When I was solving the problem D from the last contest Codeforces Round 1070 (Div. 2), in the contest i wrote the dp arguments like (vertex v, parent of vertex v), it gave TLE see my submission, and using some optimizations i reduced the dp arguments to just 1 and it was the index of the edge, and same it gave TLE :-(
in the contest I was able to optimize this solution using segment tree and binary search and finally it gave AC!
but after the contest I just changed a small thing in my first submission instead of having arguments like (vertex v, parent of vertex v), I changed it to (vertex v, the value of the parent of vertex v) and it was passed!!, see my submission
Can anyone tell me how that happened?
Thanks!




