当前位置: 首页 > news >正文

ftp怎么做网站/网络推广营销公司

ftp怎么做网站,网络推广营销公司,重庆网站建设公司那好,常州微信网站建设信息网络流24题之 1738: 最小路径覆盖问题 最小路径覆盖问题 模板题&#xff0c;求一个图的最小路径覆盖&#xff0c;输出边数和&#xff0c;路径。不会输出路径的跑dinic然后把图输出来就懂了。 #include <bits/stdc.h>using namespace std;int k;struct Dinic {static cons…

网络流24题之 1738: 最小路径覆盖问题

最小路径覆盖问题

模板题,求一个图的最小路径覆盖,输出边数和,路径。不会输出路径的跑dinic然后把图输出来就懂了。

#include <bits/stdc++.h>using namespace std;int k;struct Dinic {static const int MAXN = 30005 + 7;static const int MAXM = 1e7 + 7;static const int INF = 0x3f3f3f3f;int n, m, s, t;int first[MAXN], cur[MAXN], dist[MAXN], sign;struct Node {int to, flow, next;} edge[MAXM];inline void init(int start, int vertex, int ss, int tt) {n = vertex, s = ss, t = tt;for(int i = start; i <= n; i++ ) {first[i] = -1;}sign = 0;}inline void addEdge(int u, int v, int flow) {edge[sign].to = v, edge[sign].flow = flow, edge[sign].next = first[u];first[u] = sign++;}inline void add_edge(int u, int v, int flow) {addEdge(u, v, flow);addEdge(v, u, 0);}int match[MAXN] = {0}, vis[MAXN] = {0};void show_graph() {int cnt = 0;for(int i = 1; i <= k; i++ ) {for(int j = first[i]; ~j; j = edge[j].next) {int to = edge[j].to, w = edge[j].flow;if(to != s && edge[j ^ 1].flow) {match[i] = to - k;}}}for(int i = 1; i <= k; i++ ) {int now = i;if(vis[i]) {continue;}while(1) {printf("%d", now);vis[now] = 1;now = match[now];if(now == 0) {cnt++;puts("");break;} else {printf(" ");}}}printf("%d\n", cnt);}inline int dinic() {int max_flow = 0;while(bfs(s, t)) {for(int i = 0; i <= n; i++ ) {cur[i] = first[i];}max_flow += dfs(s, INF);}return max_flow;}bool bfs(int s, int t) {memset(dist, -1, sizeof(dist));queue<int>que;que.push(s), dist[s] = 0;while(!que.empty()) {int now = que.front();que.pop();if(now == t) {return 1;}for(int i = first[now]; ~i; i = edge[i].next) {int to = edge[i].to, flow = edge[i].flow;if(dist[to] == -1 && flow > 0) {dist[to] = dist[now] + 1;que.push(to);}}}return 0;}int dfs(int now, int max_flow) {if(now == t) {return max_flow;}int ans = 0, next_flow = 0;for(int &i = cur[now]; ~i; i = edge[i].next) {int to = edge[i].to, flow = edge[i].flow;if(dist[to] == dist[now] + 1 && flow > 0) {next_flow = dfs(to, min(max_flow - ans, flow));ans += next_flow;edge[i].flow -= next_flow;edge[i ^ 1].flow += next_flow;if(ans == max_flow) {return max_flow;}}}if(ans == 0) {return dist[now] = 0;}return ans;}} cwl;int main() {int n, m;while(~scanf("%d %d", &n, &m)) {cwl.init(0, 2 * n + 1, 0, 2 * n + 1);for(int i = 1; i <= n; i++ ) {cwl.add_edge(0, i, 1);cwl.add_edge(i + n, 2 * n + 1, 1);}for(int i = 1; i <= m; i++ ) {int u, v;scanf("%d %d", &u, &v);cwl.add_edge(u, v + n, 1);}cwl.dinic();k = n;cwl.show_graph();}return 0;
}

转载于:https://www.cnblogs.com/Q1143316492/p/9403632.html

http://www.jmfq.cn/news/5029291.html

相关文章:

  • 徐州招聘网站哪个好/seo的培训课程
  • 免费网站空间论坛/社群营销方案
  • 高端网站开发培训价格/想找搜索引擎优化
  • 世界新闻网是什么网站/怎么样建网站
  • 正规网站优化公司/整站优化和关键词优化的区别
  • wordpress备份文章/seo站长网怎么下载
  • 免费小程序模板/windows优化大师要钱
  • 抖音网络工作室/宁波seo在线优化哪家好
  • 制作网站需要用什么软件/谷歌关键词搜索工具
  • 开源saas多用户建站系统/全网引流推广
  • 建设个网站需要什么/线上推广策划方案范文
  • 公司做网站 微信平台/推广app
  • 阳光保险官方网站/制作网页链接
  • 做教育网站挣钱/网络推广怎么赚钱
  • 管理咨询公司项目运作流程图/宁波企业seo服务
  • 遵义做网站公司/上海seo有哪些公司
  • 中国数据域名注册/点金推广优化公司
  • wordpress 活动网站/北京网络推广
  • 网站电线电话图怎么做/网络销售网站
  • 找人做菠菜网站需要多少钱/汕头网站建设优化
  • 湛江网站制作系统/长春网站建设模板
  • 做网站的人多吗/首页
  • 阿里巴巴网站如何做免费推广/seo项目经理
  • 做那种网站受欢迎/如何在百度上添加自己的店铺
  • 网站建设营销型/win7优化大师
  • 免费教育网站建设/网站seo好学吗
  • 网站哪个公司做的比较好/谷歌推广运营
  • 为什么不用h5做网站/51链
  • 北京人民政府门户网站/网络推广怎么做才有效
  • 钓鱼网站排名假冒建设银行最多/百度秒收录软件工具