Блог пользователя Mohamed.Bassem

Автор Mohamed.Bassem, 11 лет назад, По-английски

Hi All, I'm getting a strange precision error in this problem : 284C - Коровки и последовательность 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 :)

  • Проголосовать: нравится
  • -13
  • Проголосовать: не нравится

»
11 лет назад, # |
Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

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

»
11 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Use long long or double. There is integer overflow.