Submission Link - CodeChef: Practical coding for everyone
Guys Can anyone tell what is the problem in the build function as i am getting Tle due to the build function. Can someone help?
Your code that gave WA , I just changed vector from call by value to call by reference , Can’t say why it gave WA , because I didn’t read your whole code neither the problem
I think issue is not in the build function as it has linear time asymptotics, in fact my solution doesn’t even have a build function. You need to implement segtree with lazy propagation.
PS: On a side note, segment tree is an overkill for this problem even a sparse table would suffice and is far cleaner ofc, sparse table solution.
1 Like