n<=200个点m<=40000条边无向图,求   t次走不经过同条边的路径从1到n的经过的边的最大值   的最小值。

最大值最小--二分,t次不重边路径--边权1的最大流。

 #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
//#include<iostream>
using namespace std; int n,m,t;
#define maxn 211
#define maxm 160011
struct Edge{int to,next,v;}edge[maxm];int first[maxn],le=;
void in(int x,int y,int v) {Edge &e=edge[le];e.to=y;e.v=v;e.next=first[x];first[x]=le++;}
void insert(int x,int y,int v) {in(x,y,v);in(y,x,v);}
const int inf=0x3f3f3f3f;
struct network
{
struct Edge{int to,next,cap,flow;}edge[maxm];int first[maxn],le,n,s,t;
void clear(int n)
{
memset(first,,sizeof(first));
le=;this->n=n;
}
void in(int x,int y,int cap) {Edge &e=edge[le];e.to=y;e.cap=cap;e.flow=;e.next=first[x];first[x]=le++;}
void insert(int x,int y,int cap) {in(x,y,cap);in(y,x,);}
int que[maxn],head,tail,dis[maxn],cur[maxn];
bool bfs()
{
memset(dis,,sizeof(dis));
dis[s]=;
que[head=(tail=)-]=s;
while (head!=tail)
{
const int now=que[head++];
for (int i=first[now];i;i=edge[i].next)
{
const Edge &e=edge[i];
if (e.cap>e.flow && !dis[e.to])
{
dis[e.to]=dis[now]+;
que[tail++]=e.to;
}
}
}
return dis[t];
}
int dfs(int x,int a)
{
if (x==t || !a) return a;
int flow=,f;
for (int &i=cur[x];i;i=edge[i].next)
{
Edge &e=edge[i];
if (dis[e.to]==dis[x]+ && (f=dfs(e.to,min(a,e.cap-e.flow)))>)
{
flow+=f;
e.flow+=f;
edge[i^].flow-=f;
a-=f;
if (!a) break;
}
}
return flow;
}
int dinic(int s,int t)
{
this->s=s;this->t=t;
int ans=;
while (bfs())
{
for (int i=;i<=n;i++) cur[i]=first[i];
ans+=dfs(s,inf);
}
return ans;
}
}g;
bool check(int x)
{
g.clear(n);
for (int i=;i<=n;i++)
for (int j=first[i];j;j=edge[j].next)
{
const Edge &e=edge[j];
if (e.v<=x) g.insert(i,e.to,);
}
return g.dinic(,n)>=t;
}
int x,y,v;
int main()
{
scanf("%d%d%d",&n,&m,&t);
int Max=;
memset(first,,sizeof(first));
for (int i=;i<=m;i++)
{
scanf("%d%d%d",&x,&y,&v);
insert(x,y,v);
Max=max(Max,v);
}
int L=,R=Max+;
while (L<R)
{
int mid=(L+R)>>;
if (check(mid)) R=mid;
else L=mid+;
}
printf("%d\n",L);
return ;
}

BZOJ1733: [Usaco2005 feb]Secret Milking Machine 神秘的挤奶机的更多相关文章

  1. [bzoj1733][Usaco2005 feb]Secret Milking Machine 神秘的挤奶机_网络流

    [Usaco2005 feb]Secret Milking Machine 神秘的挤奶机 题目大意:约翰正在制造一台新型的挤奶机,但他不希望别人知道.他希望尽可能久地隐藏这个秘密.他把挤奶机藏在他的农 ...

  2. 【bzoj1733】[Usaco2005 feb]Secret Milking Machine 神秘的挤奶机 二分+网络流最大流

    题目描述 Farmer John is constructing a new milking machine and wishes to keep it secret as long as possi ...

  3. BZOJ 1733: [Usaco2005 feb]Secret Milking Machine 神秘的挤奶机 网络流 + 二分答案

    Description Farmer John is constructing a new milking machine and wishes to keep it secret as long a ...

  4. BZOJ 1733: [Usaco2005 feb]Secret Milking Machine 神秘的挤奶机

    Description 约翰正在制造一台新型的挤奶机,但他不希望别人知道.他希望尽可能久地隐藏这个秘密.他把挤奶机藏在他的农场里,使它不被发现.在挤奶机制造的过程中,他需要去挤奶机所在的地方T(1≤T ...

  5. [BZOJ 1733] [Usaco2005 feb] Secret Milking Machine 【二分 + 最大流】

    题目链接:BZOJ - 1733 题目分析 直接二分这个最大边的边权,然后用最大流判断是否可以有 T 的流量. 代码 #include <iostream> #include <cs ...

  6. POJ 2455 Secret Milking Machine(搜索-二分,网络流-最大流)

    Secret Milking Machine Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9658   Accepted: ...

  7. POJ2455 Secret Milking Machine

    Secret Milking Machine Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12324   Accepted ...

  8. POJ 2455 Secret Milking Machine(最大流+二分)

    Description Farmer John is constructing a new milking machine and wishes to keep it secret as long a ...

  9. 【poj2455】 Secret Milking Machine

    http://poj.org/problem?id=2455 (题目链接) 题意 给出一张n个点,p条边的无向图,需要从1号节点走到n号节点一共T次,每条边只能经过1次,问T次经过的最大的边最小是多少 ...

随机推荐

  1. CF750D New Year and Fireworks

    题意: 放烟花. 一个烟花从某一起点开始,沿着当前方向移动指定数量的格子之后爆炸分成两部分,分别沿着当前方向的左上和右上方向移动.而每一部分再沿着当前方向移动指定数量的格子之后爆炸分成两部分.如此递归 ...

  2. RPC之远程过程调用

    一. 简介 将一个函数运行在远程计算机上并且等待获取那里的结果,这个称作远程过程调用(Remote Procedure Call)或者 RPC. RPC是一个计算机通信协议. 1. 类比: 将计算机服 ...

  3. Azure ARMTemplate模板,VM扩展命令

    Azure ARM模板中,给虚拟机安装扩展脚本的命令 "resources": [ { "apiVersion": "[variables('apiV ...

  4. 洛谷 P3178 [HAOI2015]树上操作

    题目描述 有一棵点数为 N 的树,以点 1 为根,且树点有边权.然后有 M 个操作,分为三种:操作 1 :把某个节点 x 的点权增加 a .操作 2 :把某个节点 x 为根的子树中所有点的点权都增加 ...

  5. uva1153 Keep the Customer Satisfied

    贪心加优先队列 (默认是小的在前,正好) //这里又很套路,设队列里的都是符合条件的考虑新加入的即可.再处理一下空队列的情况.很完美// 截止时间短的在前面,干的就多先根据截止日期排序优先队列根据完成 ...

  6. tomcat 虚拟目录配置

    1.虚拟目录优点 原始 拷贝到webapps下,然后启动tomcat,就可以访问webapps下的项目.eclipse配置tomcat的原理也是这种方式. 虚拟目录 定位到eclipse工作目录下,实 ...

  7. project .mpp 查看当天工作任务 1.选择自己 2.选择起始和终止时间 就显示当天的任务了

    project .mpp 查看当天工作任务 1.选择自己 2.选择起始和终止时间 就显示当天的任务了

  8. c++调用com口操作autocad

    #include "stdafx.h" #include <atlcomcli.h> #import "D:\\C++test\\FirstCom\\Rele ...

  9. python基础一 day3 列表

    字符串是有序的,列表也是有序的,有索引值,可以切片 可以用切片来截取列表中的任何部分返回得到一个新列表. 列表方法: 1:增加 结果: 例子:    结果: int类型不可迭代      结果: 删: ...

  10. vs2010的资源视图中,对话框显示数字的解决方法之一

    以上是不正常显示. 我这次遇到该问题的原因是资源名IDD_DLG_INTENSITY重复定义导致的, 所以在resource.h文件中去除重复定义就好了. 正常应该显示DD_XXX,如下图所示