Hello guys! I personally would request @likecs to at least explain his solution because I saw his submission took very less execution time and I am learning Segment Tree too. Also the editorials he posted for LunchTime were just amazing!! Thanks for the help :) asked 29 Aug '17, 00:54

Let us take an example, $A = [a,\ b,\ c]$ The subsequences of $A$ with their PooPoo sum are:
If we add them, we get : $4[(a^2 + b^2 + c^2)\ \ (ab + bc)]$ For 4 elements, we get : $8[(a^2 + b^2 + c^2 + d^2)\ \ (ab + bc + cd)]$ As you would have guessed from the pattern, the answer for array $A$ of $n$ elements is: $$ 2^{n1}\ \Big(\ \sum_{i\ =\ 1}^{n}\ A_i^2\  \sum_{i\ =\ 1}^{n1}\ A_i * A_{i+1}\ \Big)$$ Now the question reduces to the following: For a given range $[L,\ R]$, find the sum of squares of the elements and the sum of the product of adjacent elements, along with point updates. The above operations deal with range sums and point updates and hence can be solved by using Segment Trees or Binary Indexed Trees (BIT) / Fenwick Tree. Here are my codes: Using Segment Tree: https://www.codechef.com/viewsolution/15108856 Using Fenwick Tree: https://www.codechef.com/viewsolution/15112212 To keep things separate, I've used one tree to store the sum of squares of elements and the other to store the sum of the product of adjacent elements. answered 29 Aug '17, 01:46

Hey! Did you solve ALATE? I got only 20 points for it. Can you please explain it so that I can pass Sub task 2 without TLE? Please provide an improvement. Here is my code.
answered 29 Aug '17, 01:31

Can we solve this problem with square root decomposition? answered 29 Aug '17, 22:20
