Read About Lazy Trees:
http://www.geeksforgeeks.org/lazy-propagation-in-segment-tree/
Build 0:
--> update and retrieval of range sum.
--> all nodes are initialized with zero.
--> initialization with given values
--> only integer values are accepted
Range Query -- O(log N)
Range Update O(log N)
Constructors:
- LazyTree()
- LazyTree(long long)
- LazyTree(long long, long long)
- LazyTree(vector)
Functions available:
- long long size()
- void update(long long, long long)
- void update(long long, long long, long long)
- long long retrieve(long long, long long)
***usage & discription: ***
- LazyTree() : creates an empty Tree. with no nodes at all. useless.
LazyTree L();
- LazyTree(long long size) : creates tree with Size = size, with default value = 0, for every node.
LazyTree L(4);
- LazyTree(long long size, long long m) : creates tree with Size = size, with default value = m, for every node.
LazyTree L(4,2);
- LazyTree(vector ) : creates a tree from the array.
vector<long long> vect(4,2); //array values can be different
LazyTree L(vect);
- long long size() : returns initialized size. useless.
- void update(long long pos, long long val) : element at position = pos, increments with value = val;
L.update(4,7);
// equivalent to L.update(4,4,7);
- void update(long long L, long long R, long long val) : range update function. increments the values = val, in the range [L,R].
L.update(4,5,7);
- long long retrieve(long long L, long long R) : query the sum in range [L,R]
L.retrieve(4,5);
(\___/)
(='.'=)
o(")(")