codeforces 723F : st-Spanning Tree】的更多相关文章

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n vertices and m edges. For each edge (u,…
Bichrome Spanning Tree 题意: 给出一个n个点,m条边的无向连通图,现在要给每条边染色,可以染成黑色或者白色. 现在要求在染色完毕后,找出一个至少包含一条黑边和一条白边的最小生成树,使其权值和为X. 问这样的染色方案有多少个? 题解: 题目要求找出一个至少包含一条黑边和白边的最小生成树,那么可能就会存在这种情况:原图的最小生成树所有边都为同色,那这不是我们要求的:我们这时就会去掉一条权值最大的边,再添一条边进来. 那么我们就可以算出包含指定边的最小生成树,方法就是先加我们指…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output A group of n cities is connected by a network of roads. There is an undirected road between every pair of cities, so there are roads in total. I…
Description There are n cities and m two-way roads in Berland, each road connects two cities. It is known that there is no more than one road connecting each pair of cities, and there is no road which connects the city with itself. It is possible tha…
Description Xenia the programmer has a tree consisting of n nodes. We will consider the tree nodes indexed from 1 to n. We will also consider the first node to be initially painted red, and the other nodes — to be painted blue. The distance between t…
题意 1-n排列,构成一个圆:1-n每个点有个值0或者1,0代表点的度为偶数,1代表点的度为计数:询问能否构成一棵树,树的连边在圆内不会相交,在圆边上可以相交,可以则输出方案. 提示 1. 首先考虑什么时候无解,显然,奇数点个数是偶数,并且>=2 2. 由奇数点个数为偶数可以发现,它们可以连到同一个偶数点上(并非直接连) 3. 剩下的偶数点可以直接顺时针串联,直到连到最近的一个奇数点上 4. 相当于每个奇数点后面有一条偶数链,或者没有偶数链只有一个奇点(这都是一样的,因为链最后一个点都只剩下一个…
E. Minimum spanning tree for each edge 题目连接: http://www.codeforces.com/contest/609/problem/E Description Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n vertices and m edges. For each edge (u, v) f…
E. Minimum spanning tree for each edge time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n …
E. Minimum spanning tree for each edge 题目连接: http://www.codeforces.com/contest/609/problem/E Description Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n vertices and m edges. For each edge (u, v) f…
E. Minimum spanning tree for each edge   Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n vertices and m edges. For each edge (u, v) find the minimal possible weight of the spanning tree that contai…