This problem is in Contest(s) below:
Contest 1223:线段树&&树链剖分
Contest 1090:线段树从入门到入门
Contest 1286:线段树从入门到入门
Contest 1418:线段树从入门到入门