本文共 1601 字,大约阅读时间需要 5 分钟。
通过这个题发现了让自己的最大流模板中怀疑了两天人生的bug
本代码留下了找bug的过程中的注释 提醒自己的sb突然又发现。。。自己写的这个模板好像不能分清正反向边
所以结构体定义要再加一个标志来分开正反向边。#includeusing namespace std;const int N = 210;const int maxn = 210;const int INF = 0x3f3f3f3f;const int inf = 0x3f3f3f3f;int st,des;int n;char mapp[maxn][maxn];int a[maxn];///终点 容量 反向边编号struct edge{ int to,cap,rev; edge(int a=0,int b=0,int c=0) { to=a; cap=b; rev=c; }};vector G[maxn];int level[maxn];///顶点到源点的距离标号int iter [maxn];///当前弧,在其之前的便已经没用了///加边void add_edge(int from,int to,int cap){ G[from].push_back(edge(to,cap,G[to].size())); ///因为G[from]添加了一个新的 所以在下面要 减1 G[to].push_back(edge(from,0,G[from].size()-1 ));}///初始化void init(int z){ for(int i=0; i
转载地址:http://qgvqz.baihongyu.com/