Segment tree is very slow!

Revision en2, by yaksha, 2018-03-08 19:37:02

Hi, So this has happened before , and it happens from time to time , only this time I really got frustrated and hence am asking this question . . Why is my segment tree so slow?

Some problems like this -> 301D - Yaroslav and Divisors , have the official solution, the same as the solution that I code but somehow my segment tree is always very slow. This has happened before in live contests as well . Maybe my implementation is very bad , that's why I want to learn where I am making mistake , and please provide me with a better implementation if I am making a mistake..

My implementation to the above problem,using segment trees, which TLE's --> 36075338 . Help me out on this please!

UPDATE: I solved the problem doing some minor optimizations like scanf/printf and using int instead of long long , but my solution is still very slow compared to other solutions..

Tags #help, segment tree, time complexity

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English yaksha 2018-03-08 19:37:02 187
en1 English yaksha 2018-03-08 18:30:55 724 Initial revision (published)