Skip to content

Commit 3997ffb

Browse files
lrvideckisweb-flow
andauthored
seg tree add vector constructor (#177)
* first draft * [auto-verifier] verify commit 2a37bed --------- Co-authored-by: GitHub <noreply@github.com>
1 parent 49fcd3e commit 3997ffb

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

.verify-helper/timestamps.remote.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table.test.cpp": "2026-01-18 11:15:41 +0000",
4545
"tests/library_checker_aizu_tests/data_structures/rmq_sparse_table_inc.test.cpp": "2026-01-18 11:15:41 +0000",
4646
"tests/library_checker_aizu_tests/data_structures/simple_tree.test.cpp": "2026-01-18 11:15:41 +0000",
47-
"tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2026-01-24 12:58:11 -0700",
48-
"tests/library_checker_aizu_tests/data_structures/simple_tree_inc_line.test.cpp": "2026-01-24 12:58:11 -0700",
47+
"tests/library_checker_aizu_tests/data_structures/simple_tree_inc.test.cpp": "2026-01-28 20:57:42 -0700",
48+
"tests/library_checker_aizu_tests/data_structures/simple_tree_inc_line.test.cpp": "2026-01-28 20:57:42 -0700",
4949
"tests/library_checker_aizu_tests/data_structures/simple_tree_line.test.cpp": "2026-01-18 11:15:41 +0000",
5050
"tests/library_checker_aizu_tests/flow/dinic_aizu.test.cpp": "2024-11-17 14:04:03 -0600",
5151
"tests/library_checker_aizu_tests/flow/hungarian.test.cpp": "2024-11-17 14:04:03 -0600",

library/data_structures_[l,r]/seg_tree.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ template<class T, class F> struct tree {
2020
vector<T> s;
2121
tree(int n, T unit, F op):
2222
n(n), op(op), s(2 * n, unit) {}
23+
#include "seg_tree_uncommon/init.hpp"
2324
void update(int i, T val) {
2425
for (s[i += n] = val; i /= 2;)
2526
s[i] = op(s[2 * i], s[2 * i + 1]);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
tree(const vector<T>& a, F op):
3+
n(sz(a)), op(op), s(2 * n) {
4+
rep(i, 0, n) s[i + n] = a[i];
5+
for (int i = n - 1; i >= 1; i--)
6+
s[i] = op(s[2 * i], s[2 * i + 1]);
7+
}

0 commit comments

Comments
 (0)