memphis24's blog

By memphis24, history, 7 years ago, In English

I have a doubt regarding the third problem of September Long challenge ,SEREJA and COMMANDS.

Can someone help me out and tell me what is wrong with my code.What I did was I iterated through all the commands backwards and for any command of type 2,first I did the query operation on the segment tree to find how many times that command was getting executed and then I performed an update operation on the segment tree in the range l to r of the type 2 command.And for all the type 1 commands if it was from l to r , all I did was first the query operation to get how many times it was getting executed(val) and then arr[l]+=val;ar[r+1]-=val; using the mod.

I was able to pass only subtask 1. Here's my code:

https://www.codechef.com/viewsolution/15378534

  • Vote: I like it
  • -6
  • Vote: I do not like it

| Write comment?
»
7 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Dude, i think , u don't know the subtraction modulus concept. (A-B)%M=(A%M — B%M + M)%M; In line 76, you are doing that mistake. Correct it , get AC and thank me after.