January 12 summarizes

Today did a few questions, to talk about feelings.

First CF11080F: the number of the minimum spanning tree.

I approach this question is: construct a minimum spanning tree, which is not enumerate other side, if adding this edge, will be able to form a ring. In this loop (apart from this edge) with edge weights equal to the maximum of this edge can be an extra minimum spanning tree. Maintenance and maximum ring, tree multiplier using it. But multiply Yi
place easy wrong, raised here:

void init(){
	  	for(int j=1;(1<<j)<=n;++j){
		  		For(i,1,n){
				if(!Fa[i][j-1]) continue;
				Fa[i][j]=Fa[Fa[i][j-1]][j-1];
				Max[i][j]=max(Max[i][j-1],Max[Fa[i][j-1]][j-1]);
		}
	}
}

It should first enumerate j j re-enumeration i i , or the update will be problems.

Then the question is a disjoint-set of weights, weights disjoint-set at the time of the merger should follow the principle of vector addition and subtraction, keeping in mind who to who to merge the above, this is a topic in some pit.

There is a HDU3191: This question has a blog put it very well, he pointed out that a lot of mistakes, can deepen understanding. Portal

Finally made a binary answer + The title topological sort: This question provides a thought, in the topological ordering, must be present to form a ring from the edge point higher order topology low order topology. Half the answer, this is very good to see, such as the different limits are very different, and there is no influence on each other, only the value associated with it.

Published 51 original articles · won praise 6 · views 20000 +

Guess you like

Origin blog.csdn.net/qq_35776579/article/details/103949401