http://blog.youkuaiyun.com/hnust_xiehonghao/article/details/9176909 将问题巧妙地转化为并查集的环 而并查集的环又巧妙地只需要在每次决定加入联通分量的情况下检查