poj 3164 Command Network#有向最小树形图

博客分享了关于POJ 3164 Command Network问题的解决方法,重点在于理解如何构建有向最小树形图。文中提供了一个模板,并探讨了相关算法思想。
摘要由CSDN通过智能技术生成

有向最小树形图,贴个模板

#include <stdio.h>
#include <string.h>
#include <math.h>

#define V 128
#define E 10240
#define typec double // type of res
const typec inf = 0x3f3f3f3f; // max of res
typec res, dis[V];
int to[V], cp[V], tag[V];

struct Edge
{
    int u, v;
    typec c;
    Edge(int a = 0,int b = 0,double cc = 0.0)
    {
        u = a;
        v = b;
        c = cc;
    }
} eg[E];
int iroot(int i){
    if (cp[i] == i) return i;
    return cp[i] = iroot(cp[i]);
}
int dirtree(int root, int nv, int ne) // root: 树根
{ // vertex: 0 ~ n-1
    int i, j, k, circle = 0;
    memset(tag, -1, sizeof(tag));
    memset(to, -1, sizeof(to));
    for (i = 0; i < nv; ++i) dis[i] &
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值