HOJ 2739 网络流【带权有向图上的中国邮路问题】

这篇博客介绍了如何使用网络流算法解决带权有向图上的中国邮路问题。通过实例解析,详细阐述了如何构建图模型并应用网络流求解,帮助读者理解这一经典问题的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

【带权有向图上的中国邮路问题】

#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long LL;
const int MAXN=110,M=400000, inf=0x3f3f3f3f;
int head[MAXN];
struct edge{
	int to,next,cost,from;
}e[M];
int anss[M],v[M];
int o,an;
void add(int x,int y,int z)
{
    ee[o].from=x;
    ee[o].to=y;
    ee[o].next=head[x];
	ee[o].cost=z;
	head[x]=o++;
}

struct MCMF
{

    struct Edge
    {
        int from,to,cap,flow,cost;
        Edge(){}
        Edge(int a,int b,int c,int d,int e):from(a),to(b),cap(c),flow(d),cost(e){}
    };

    int n,m,s,t;
    vector<Edge> edges;
    vector<int> G[MAXN];
    int inq[MAXN],d[MAXN],p[MAXN],a[MAXN];
    queue<int> Q;

    void init(int n)
    {
        this->n=n;
        for(int i=0;i<n;++i) G[i].clear();
        edges.clear();
    }

    void AddEdge(int from,int to,int cap,int cost)
    {   //printf("%d %d %d %d\n",from
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值