You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and fails the assert. This code is meant to compute the sum of absolute value of differences between all pairs of elements in a sorted array.
When I remove the if condition in https://github.com/atcoder/ac-library/blob/master/atcoder/lazysegtree.hpp#L135 as well as the one on L136, the code works on this case. I won't go into full detail for now, but basically, there is a node the value of which needs to be updated (to be equal to the sum of those of its two children), and that if condition is getting in the way.
Moreover, even after I removed that aforementioned if, the value of res at the end for a = {3, 3, 4} is 2 when it should be 4.
I actually examined the case of a = {2, 5, 5} closely (ran thru with many debug print statements) but have yet to look into that of a = {3, 3, 4}, would be happy to discuss. Feel free to contact me via email at guoyiz at yandex.ru. Thank you!
The text was updated successfully, but these errors were encountered:
Per yosupo06/library-checker-problems#1137 (comment) looks like I had used it wrong. Sorry about that. Surely, it was very difficult for me to believe that there could actually be something wrong with such a commonly used library.
The above code prints
and fails the
assert
. This code is meant to compute the sum of absolute value of differences between all pairs of elements in a sorted array.When I remove the
if
condition in https://github.com/atcoder/ac-library/blob/master/atcoder/lazysegtree.hpp#L135 as well as the one onL136
, the code works on this case. I won't go into full detail for now, but basically, there is a node the value of which needs to be updated (to be equal to the sum of those of its two children), and thatif
condition is getting in the way.I was led to this by https://atcoder.jp/contests/abc351/tasks/abc351_e.
Moreover, even after I removed that aforementioned
if
, the value ofres
at the end fora = {3, 3, 4}
is2
when it should be4
.I actually examined the case of
a = {2, 5, 5}
closely (ran thru with many debug print statements) but have yet to look into that ofa = {3, 3, 4}
, would be happy to discuss. Feel free to contact me via email atguoyiz at yandex.ru
. Thank you!The text was updated successfully, but these errors were encountered: