博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
「BZOJ2879」[Noi2012]美食节
阅读量:4308 次
发布时间:2019-06-06

本文共 915 字,大约阅读时间需要 3 分钟。

这道题就是  的加强版

如果一开始把全部边连上会T

优化的方法是只连用到过和下一次增广可能用到的边。

1 #include
2 using namespace std; 3 const int N=50,M=110,NN=100010,oo=1e9; 4 int n,m,cost[N][M],tot,s,t,p[N],rank[NN],c[NN]; 5 bool isend[NN]; 6 struct Edge{ 7 int from,to,flow,cap,w; 8 }; 9 int edge_tot;10 vector
edge;11 vector
point[NN];12 void add_edge(int f,int t,int cc,int ww){13 edge.push_back((Edge){f,t,0,cc,ww});14 point[f].push_back(edge_tot++);15 edge.push_back((Edge){t,f,0,0,-ww});16 point[t].push_back(edge_tot++);17 return;18 }19 int dis[NN],pre[NN];20 bool inq[NN];21 bool spfa(){22 queue
q;23 int x;24 for(int i=1;i<=tot;i++) dis[i]=oo;25 q.push(s);26 dis[s]=0,inq[s]=1;27 while(!q.empty()){28 x=q.front();q.pop();29 inq[x]=0;30 for(int i=0;i

 

转载于:https://www.cnblogs.com/mycups/p/8528851.html

你可能感兴趣的文章
根据图层名获取图层和图层序号
查看>>
规范性附录 属性值代码
查看>>
提取面狭长角
查看>>
Arcsde表空间自动增长
查看>>
Arcsde报ora-29861: 域索引标记为loading/failed/unusable错误
查看>>
记一次断电恢复ORA-01033错误
查看>>
C#修改JPG图片EXIF信息中的GPS信息
查看>>
从零开始的Docker ELK+Filebeat 6.4.0日志管理
查看>>
How it works(1) winston3源码阅读(A)
查看>>
How it works(2) autocannon源码阅读(A)
查看>>
How it works(3) Tilestrata源码阅读(A)
查看>>
How it works(12) Tileserver-GL源码阅读(A) 服务的初始化
查看>>
uni-app 全局变量的几种实现方式
查看>>
echarts 为例讲解 uni-app 如何引用 npm 第三方库
查看>>
uni-app跨页面、跨组件通讯
查看>>
springmvc-helloworld(idea)
查看>>
JDK下载(百度网盘)
查看>>
idea用得溜,代码才能码得快
查看>>
一篇掌握python魔法方法详解
查看>>
数据结构和算法5-非线性-树
查看>>