线段树:
http://www.tuicool.com/articles/jaINruq
并查集:
http://blog.csdn.net/lalor/article/details/7388524
http://www.cnblogs.com/ktyanny/archive/2009/12/09/1620043.html
http://blog.csdn.net/shahongzhou/article/details/8957886
http://www.docin.com/p-729406917.html