Блог пользователя Boring_Day

Автор Boring_Day, история, 4 года назад, По-английски

If it is possible to create a vector of class then it should not be an issue to create vector of segment tree in c++.

Can you help me in these two things.

1st) when the size of segment tree at each index is same.

2nd) when the sizes at different indices are different.

Even if you help me solve the 1st thing i will be thankful to you.

  • Проголосовать: нравится
  • -10
  • Проголосовать: не нравится

»
4 года назад, скрыть # |
← Rev. 5  
Проголосовать: нравится 0 Проголосовать: не нравится

It seems that you just want a segment tree encapsulated by a class like this

Spoiler
»
4 года назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

You can use this. It'll work out of the box for same size segment trees. If you want to add variable size segment trees to it just give the class a default constructor and emplace_back the segtrees as required.

auto merge = [&](int a, int b) { return a+b; };
using ST = Segtree<int, decltype(merge)>;
vector<ST> arr(n, ST(n, 0, merge));
// or arr.emplace_back(n, 0, merge);