Mohamed.Bassem's blog

By Mohamed.Bassem, 11 years ago, In English

Hi All, I'm getting a strange precision error in this problem : 284C - Cows and Sequence and this is my code : 3346105 I know that this problem could be solved by many other ways , but what's wrong with this implementation ? I'm using a segment tree with lazy propagation , every node contains three integers , the value of the node ( which is the summation over this range ) the update flag ( and value ) and the number of leafs under this node.

Thanks :)

UPDATE : The problem was that integers overflow and the size of the vector was causing some problems too , Thanks to EarlOfDitches and here is my accepted solution 3348952 :)

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

»
11 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

Most probably, the issue is in data overflow. You used int type for sum, use 64-bit integers.

»
11 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Use long long or double. There is integer overflow.