Pls have a look at this Question on codechef
http://www.codechef.com/problems/FLIPCOIN/
i tried this using Segment tree...
i implemented segment updating properly....
but dont know how to do segment Querying in this particular Question
although point Querying is easy..
and please suggest links and ebooks for topics such as segment tree.
Interval tree , Binary Indexed tree , Suffix trees(Other than Topcoder
Tutorials)
This is how i implemented Segment updating:

void update(int beg,int end,int ind)    //segment updating
{
        if(beg>B || end<A) return;
        if(beg>=A && end<=B) m[ind]+=k;
        else
        {
                update(beg,((beg+end)>>1),(ind<<1));
                update(1+((beg+end)>>1),end,1+(ind<<1));
        }
}

may be u need to change for Querying....

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to