参考:https://www.cnblogs.com/ivanovcraft/p/9019090.html

模板:https://www.luogu.com.cn/problem/P3384

1、线段树 https://blog.nowcoder.net/n/e57e3d13cf4d4c68a6a92409cd36e997