MARBLEGF - Editorial

Could this problem be solved using a segment tree ? From what i have read up a segment tree requires ( 2*2^(log n base 2) -1 ) memory for array of size n .Now i tried submitting a solution using segment tree . Here is the link . However i get sigsegv error. Any way you’ll could assist me on this .

well with me…i solved this problem with initialy constructing a segment tree and storing all the updates .

thanks guys…

@xellos0 as i can understand ur code ur code also taking O(nlogn+Qlogn) since ur put() function taking logN time and u r calling this function after taking the N input and of query type “T” & “G”. BTW ur code is really amaZing :smiley:

@newbie456 although im going through ur code i coudnt understand ur code how the prefix sum is working .can u give some reference to it.

segment tree or BIT, more or less the same thing