From TLE to AC using magic!

Правка en1, от Top12, 2025-12-13 23:04:43

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!

Теги dp, magic ac

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Top12 2025-12-13 23:04:43 918 Initial revision (published)