naruto_returns's blog

By naruto_returns, history, 4 years ago, In English

Question :- Range Updates and Sums on cses Link The 2nd test case is failing for 45 queries rest (65k queries) are correct. I am not able to find the logical mistake in lazy updates part. Please can you help to solve this

Update:- The Problem was in update part of lazy rest of the code is right.

Non-Working Code
Updated and working code
  • Vote: I like it
  • +1
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it -18 Vote: I do not like it

post this with your original handle, then we will help

»
4 years ago, # |
  Vote: I like it -26 Vote: I do not like it

You don't need segment trees you can do this just by using map.

»
4 years ago, # |
  Vote: I like it +1 Vote: I do not like it

You can also solve it with Prefix Sums over the array and SQRT Decomp. on the queries.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    I thought about using sqrt decomposition, but the thing is it might tle.