警示后人
查看原帖
警示后人
775179
rhineofts楼主2023/7/25 19:28

考虑这组数据:

2
1000000 -1000000

如果你用 set,初始插入的两个 inf 和 -inf 值为 2×106+102\times10^6+10, 那么第二次更新时

auto it1 = s.lower_bound(-100000); 
auto it2 = it1--;

中的 *it1 值为 −2000010-2000010,*it2 的值为 10000001000000 ,而 −1000000−(−2000010)=1000010-1000000- (-2000010)=1000010 是小于 1000000−(−1000000)=20000001000000-(-1000000)=2000000 的,这样更新答案就会出错,因此,inf 值不能小于 3×1063\times10^6

2023/7/25 19:28
加载中...