poj 2112 k个挤奶机每天可以给头奶牛让到达大距离小一些代码流.pdfVIP

  • 1
  • 0
  • 约3.51千字
  • 约 3页
  • 2025-06-30 发布于北京
  • 举报

poj 2112 k个挤奶机每天可以给头奶牛让到达大距离小一些代码流.pdf

POJ2112k个挤奶机,每天可以给m头奶牛挤奶,让奶牛到达挤奶机的最大距离最小

思路:先用floyd求解任意两点之间的最短距离,再构建网络,将牛与源点相连容量为1,

将机器与汇点相连容量为m。然后我们二分枚举答案,将牛与机器之间连线小于枚举值得边

加入网络,大于枚举值得边去掉。然后求解最大流

#includeiostream

#includecstdio

#includecstdlib

#includecstring

#includecmath

#includevector

#includequeue

#includeiomanip

#includealgorithm

usingnamespacestd;

typedeflonglongLL;

constintmod=1e9+7;

constdoubleeps=1e-12;

constintinf=1000000;//不要设INT_MAX,floyd的时候会出问题

intc,k,s,t,n,m;

intmap1[300][300];

intflow_map[300][300];

intlevel[300];

voidbuild(intmaxs)

{

文档评论(0)

1亿VIP精品文档

相关文档