diff --git a/trees/segtree_persistent.cc b/trees/segtree_persistent.cc index d7e2a9c..66f54af 100644 --- a/trees/segtree_persistent.cc +++ b/trees/segtree_persistent.cc @@ -8,7 +8,6 @@ template struct segtree { vector d; vector version_root; size_type _max; - void _copy(size_type& virt) { int o = virt; virt = d.size(); @@ -45,6 +44,7 @@ template struct segtree { _copy(d[p].rson); _set(m + 1, t, d[p].rson, x, c); } + d[p].info = d[d[p].lson].info + d[d[p].rson].info; } size_type _clone(size_type version) { d.emplace_back(d[version_root[version]]); @@ -77,11 +77,9 @@ template struct segtree { return range_query(version, loc, loc); } }; - struct Info { - int val; + int val = INF; }; - Info operator+(const Info& lhs, const Info& rhs) { - return { lhs.val + rhs.val }; + return { min(lhs.val, rhs.val) }; }