kmyk / competitive-programming-library

kimiyuki's library for competitive programming with C++
https://kmyk.github.io/competitive-programming-library
MIT License
66 stars 10 forks source link

Error in segment tree beats implementation #10

Closed peltorator closed 3 years ago

peltorator commented 3 years ago

Here you add g to lazy_add and lazy_update. But here you first apply update and then add. So you'll add g twice. I think you just need to delete lines 171-173

kmyk commented 3 years ago

It seems correct with the current implementation because:

  1. in the pushdown method, it returns from the method and doesn't add after applying update, and
  2. deleting lines 171-173 makes the tests using DSL_2_G and DSL_2_H fail.

However, anyway, thank you for telling me a possible bug!