#### Category : segment-tree

So I’m looking to represent non-overlapping ranges in an N dimensional space. I think CGAL has this functionality, and facilitates fast querying of points as the example shows below. What I’m not sure of is how to extend this kind of query to find open windows. So in this case I make 2 rectangles and ..

Read more

So I’m looking to represent non-overlapping ranges in an N dimensional space. I think CGAL has this functionality, and facilitates fast querying of points as the example shows below. What I’m not sure of is how to extend this kind of query to find open windows. So in this case I make 2 rectangles and ..

Read more

Trying to code segment tree for a very basic question called Range Minimum Query 1 from CSES. Basicly I have to find the minimum number from a range of numbers from an array. But I am getting some ambiguous error can’t understand with it means. #include<iostream> using namespace std; const int mxN = 2e5+5; int ..

Read more

I have a range of numbers in a list and i want XOR a subset of this with specific number.( at first all numbers in list are 0) i want to implement this list in a segment tree and update this segment tree ( after XOR a subset with specific number ) as fastest way. ..

Read more

What should I give the value for pos if i know start and end of a query? for eg array 1 2 3 4 5 and I have query l = 3, r = 5(1-based index), so answer is 3(3,4,5) now calling the findMax function is like findMax(tree, ??? , 0, n-1, l – 1, ..

Read more

I know simple sparse tree which process idempotent functions in O(1) have completely different formation than segment tree where function f can be minimum function. like formation of simple sparse tree is as follows for (int i = 0; i < N; i++) st[i] = f(array[i]); for (int j = 1; j <= K; j++) ..

Read more

Can’t understand the requirement of t[i<<1|1] in build() function of seg tree. isn’t it equivalent to t[i<<1] ? const int N = 1e5; // limit for array size int n; // array size int t[2 * N]; void build() { // build the tree for (int i = n – 1; i > 0; –i) ..

Read more

Please help me find the mistake in the code. This is part of segment tree query which will return the number of elements divisible by 5 in a range. The indexing of segment tree here starts with 0. Here fl and fr denotes the query range to find. Initially 0 and (length of original array) ..

Read more