ADDMUL - Editorial

What’s wrong with my solution?
https://www.codechef.com/viewsolution/7919583

1 Like

[JBAB5E - Online C++0x Compiler & Debugging Tool - Ideone.com][1]

Can you please check my code? What’s wrong with it?
[1]: JBAB5E - Online C++0x Compiler & Debugging Tool - Ideone.com

Very nice question to implement lazy propagation :slight_smile:

can anybody tell me what’s wrong with my solution?

here is the solution :
[solution][1]
[1]: CodeChef: Practical coding for everyone

Before switching to segtree i did square root decomposition CodeChef: Practical coding for everyone . It worked for 1st 2nd and 4th subtask but not for 3rd subtask .

3 Likes

@rajat1603: did you try applying fast I/O to your solution? it may get AC.

I think your code is update all the elements in the range as you are using the statement - if(st!-end)… i.e. you are not using lazy propagation. Lazy means to update when and only required, update it leaf nodes and return immediately. For details refer to SPOJ Discussion board… Also, Please indent your code for others to understand it easily…

Yes someone please explain