1
0
Fork 0

Update trees/segtree_persistent.cc

Signed-off-by: subcrip <contact@subc.rip>
This commit is contained in:
subcrip 2024-12-12 12:13:41 +00:00
parent e254c0f0cd
commit 5520956d83
1 changed files with 3 additions and 5 deletions

View File

@ -8,7 +8,6 @@ template <typename Addable_Info> struct segtree {
vector<Node> d; vector<Node> d;
vector<size_type> version_root; vector<size_type> version_root;
size_type _max; size_type _max;
void _copy(size_type& virt) { void _copy(size_type& virt) {
int o = virt; int o = virt;
virt = d.size(); virt = d.size();
@ -45,6 +44,7 @@ template <typename Addable_Info> struct segtree {
_copy(d[p].rson); _copy(d[p].rson);
_set(m + 1, t, d[p].rson, x, c); _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) { size_type _clone(size_type version) {
d.emplace_back(d[version_root[version]]); d.emplace_back(d[version_root[version]]);
@ -77,11 +77,9 @@ template <typename Addable_Info> struct segtree {
return range_query(version, loc, loc); return range_query(version, loc, loc);
} }
}; };
struct Info { struct Info {
int val; int val = INF;
}; };
Info operator+(const Info& lhs, const Info& rhs) { Info operator+(const Info& lhs, const Info& rhs) {
return { lhs.val + rhs.val }; return { min(lhs.val, rhs.val) };
} }