Example #1
0
void solve2(int l,int r)
{
	int n = cyc.size();
	
	ans -= c.ask(1,1,n,l,r);
	//cerr<<ans<<' ';
	c.update(1,1,n,l,r);
	ans += c.ask(1,1,n,l,r);
	//cerr<<ans<<'\n';
}
Example #2
0
	data ask(int _l,int _r)
	{
		if ( _l > rt || _r < lt )
			return data();
		if ( _l <= lt && rt <= _r )
			return x;
			
		int md = (lt+rt)/2;
		
		if ( l == NULL ) l = new seg(lt,md);
		if ( r == NULL ) r = new seg(md+1,rt);
		
		return l->ask(_l,_r) + r->ask(_l,_r);
	}