题意:n点,m条边。m条边里面标记为1的最小生成树的边,0为非最小生成树的边。给了每条边的权,如果能构成一个最小生成树则输出图,否则-1。
思路:先按权值小,为生成数边的顺序排序。(根据kruskal)再添加每条0边。这里假定(1,3),(2,4)构成环。
1 #include2 #include 3 #include 4 #include 5 #include 6 #include 7 #include
本文共 1100 字,大约阅读时间需要 3 分钟。
题意:n点,m条边。m条边里面标记为1的最小生成树的边,0为非最小生成树的边。给了每条边的权,如果能构成一个最小生成树则输出图,否则-1。
思路:先按权值小,为生成数边的顺序排序。(根据kruskal)再添加每条0边。这里假定(1,3),(2,4)构成环。
1 #include2 #include 3 #include 4 #include 5 #include 6 #include 7 #include
转载于:https://www.cnblogs.com/ITUPC/p/5040992.html