转载来自:http://www.cnblogs.com/huangfeihome/archive/2012/09/07/2675123.html并查集。 首先,以为k个询问中的I是乱序的,直接被吓傻了,后来看讨论版才发现I是升序的…… 这道题让我对并查集有一个新的认识:根的代表性是非常强的!并查集里如果某个节点的改动会影响到整个并查集的所有节点,那么,在union_set的时候只需要改动根节点就可以了,当然,在find_set函数里要对所有节点进行更新(这相当于一种延时标记)。我们知道,find_set函数走了两条路,一条是前往根的路,一条是从跟返回的路,那么,如果发现根已经被改动,必须在.. Read More
posted @ 2013-04-08 21:54 free斩 Views(162) Comments(0) Diggs(0) Edit
Find them, Catch themTime Limit:1000MSMemory Limit:10000KTotal Submissions:23915Accepted:7167DescriptionThe police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon and Gang Snake. However, the police first needs to identify whi Read More
posted @ 2013-04-08 19:04 free斩 Views(318) Comments(0) Diggs(0) Edit