poj 2391 Ombrophobic Bovines, 最大流, 拆点, 二分 dinic /* * Author: yew1eb * Created Time: 2014年10月31日 星期五 15时39分22秒 * File Name: poj2391.cpp */ #include <ctime> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring&g…
Ombrophobic Bovines Time Limit: 1000MSMemory Limit: 65536K Total Submissions: 14519Accepted: 3170 Description FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain makes them shake in their hooves. They have de…
题目链接 题意:农场有F(1 <= F <= 200)片草地用于放牛,这些草地有P(1 <= P <= 1500)连接,农场的草地上有一些避雨点,奶牛们可以在避雨点避雨,但是避雨点的大小是有限的,所以有的时候需要经过道路去其他避雨点避雨,而经过道路是需要时间的,求出所有奶牛进入避雨点所需要的最小时间,如果不能是所有奶牛进入避雨点,输出-1:每块草地上的奶牛数量范围为(1-1000),草地避雨点的范围为(1--1000)经过道路的时间范围为(1--1000000000) floyd:…
Ombrophobic Bovines Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18623   Accepted: 4057 Description FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain makes them shake in their hooves. They h…
Ombrophobic Bovines Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11651   Accepted: 2586 Description FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain makes them shake in their hooves. They h…
http://poj.org/problem?id=2391 题意: 给定一个无向图,点i处有Ai头牛,点i处的牛棚能容纳Bi头牛,求一个最短时间T,使得在T时间内所有的牛都能进到某一牛棚里去. 思路: 建立一个源点和汇点,源点和牛棚的初始牛量相连,汇点和牛棚容量相连.这样跑最大流,如果最后流量等于牛的总数时,就说明是可以的. 那么,怎么连边呢?二分时间,根据时间来连边,所以首先我们先跑一遍floyd计算出两点距离.然后在该时间下,如果d[i][j],那么就添加边(i,i',INF),表面这段路…
[题意]有n块草地,一些奶牛在草地上吃草,草地间有m条路,一些草地上有避雨点,每个避雨点能容纳的奶牛是有限的,给出通过每条路的时间,问最少需要多少时间能让所有奶牛进入一个避雨点. 和POJ2112很类似,都是使最大的走过路径长度和最小的题,也是先Floyd再二分求最大流看是否满流--昨天刚做啊,第一下竟然没看出来,真是太年轻太Naive了!--=_= [思路]拆点建图,每个点的(in)和(out)间容量oo,源点向每个有牛的点(in)连边,容量为该点的牛数,每个有避雨点的点(out)向汇点连边,…
题目链接 题意 有\(n\)个牛棚,每个牛棚初始有\(a_i\)头牛,最后能容纳\(b_i\)头牛.有\(m\)条道路,边权为走这段路所需花费的时间.问最少需要多少时间能让所有的牛都有牛棚可待? 思路 二分 因为问题具有单调性,因此考虑二分时间,\(check\)是否满足条件. 满足条件指什么呢? 是指所有的牛都有牛棚可待. 是指所有的牛都顺利地从某一个牛棚移动到了另一个合法的牛棚(或者不移动),而这个移动是在限定的时间范围内的. 建图 首先拆点,将牛棚拆成 初始牛棚 与 终态牛棚. 在 源点…
题意 : 给出一些牛棚,每个牛棚都原本都有一些牛但是每个牛棚可以容纳的牛都是有限的,现在给出一些路与路的花费和牛棚拥有的牛和可以容纳牛的数量,要求最短能在多少时间内使得每头牛都有安身的牛棚.( 这里注意给出的边是无向边且有重边 ) 分析 : 听说是网络流的经典题型,这里先来讲一下如何转化为最大流然后二分求解. ① 先来说一下最大流在这题 ”扮演的角色" 先不考虑牛棚之间花费的关系,先抽象出原本没有的两个点,一个源点和一个汇点,设置源点到各个牛棚边的容量为牛棚原有的牛数,设置各个牛棚到汇点边的容量…
实际上是求最短的避雨时间. 首先将每个点拆成两个,一个连接源点,一个连接汇点,连接源点的点的容量为当前单的奶牛数,连接汇点的点为能容纳的奶牛数. floyd求任意两点互相到达的最短时间,二分最长时间,最大流判断是否可行. 注意路径时间会超过int /* 最大流SAP 邻接表 思路:基本源于FF方法,给每个顶点设定层次标号,和允许弧. 优化: 1.当前弧优化(重要). 1.每找到以条增广路回退到断点(常数优化). 2.层次出现断层,无法得到新流(重要). 时间复杂度(m*n^2) */ #incl…
<题目链接> 题目大意: 给定一个有$n$个顶点和$m$条边的无向图,点$i$ 处有$A_i$头牛,点$i$ 处的牛棚能容纳$B_i$头牛,每条边有一个时间花费$t_i$(表示从一个端点走到另一个端点所需要的时间),求一个最短时间T使得在T时间内所有的牛都能进到某一牛棚里去.$(1 <= N <= 200, 1 <= M <= 1500,0 <= A_i <= 10^3, 0 <= B_i <= 10^3, 1 <= Dij <= 1…
我%--&(¥--,调了一下午,最后发现P赋值1e5能过,赋值1e6就会TLE致死.改了一下午加一晚上然而这是为什么??? 一种常见的建图套路,首先二分答案,注意上界要取大一点,1e9是不行的.然后问题变为判定,首先弗洛伊德求出点两两之间的最短距离.每次建图时把点拆成两个,然后s向所有的i连容量为a[i]的边,所有i+n向t连容量为b[i]的边.对于原图中的一条边(u,v),如果长度小于等于当前二分的mid的,连接u和v+n,容量为inf.(因为可以同时走) 记得来long long #incl…
[题目大意]给定一个无向图,点i处有Ai头牛,点i处的牛棚能容纳Bi头牛,求一个最短时间T使得在T时间内所有的牛都能进到某一牛棚里去.(1 <= N <= 200, 1 <= M <= 1500, 0 <= Ai <= 1000, 0 <= Bi <= 1000, 1 <= Dij <= 1,000,000,000) 一开始想拆点建图,0到x集合为汇,值为各个区域的牛数量, Y到终点连边,值为各个区域的容量,然后就是看怎么连x和y了 我一开始把可…
题目大意:F个草场,P条道路(无向),每个草场初始有几头牛,还有庇护所,庇护所有个容量,每条道路走完都有时间,问所有奶牛都到庇护所最大时间最小是多少? 思路:和POJ2112一样的思路,二分以后构建网络流跑就行TUT,问题是,这题是无向边!!无向边啊 题目还给出 3 2 702 3 90这么让人觉得是有向边的数据,纠结过这个之后再把数组开小点(开打了会TLE )然后就能AC了 #include <stdio.h> #include <iostream> #include <s…
Ombrophobic Bovines Time Limit: 1000MSMemory Limit: 65536K Total Submissions: 21660Accepted: 4658 题目链接:http://poj.org/problem?id=2391 Description: FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain makes the…
一道水题WA了这么多次真是.... 统考终于完 ( 挂 ) 了...可以好好写题了... 先floyd跑出各个点的最短路 , 然后二分答案 m , 再建图. 每个 farm 拆成一个 cow 点和一个 shelter 点, 然后对于每个 farm x : S -> cow( x ) = cow( x ) 数量 , shelter( x ) -> T = shelter( x ) 容量 ; 对于每个dist( u , v ) <= m 的 cow( u ) -> shelter( v…
Ombrophobic Bovines Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19553   Accepted: 4217 Description FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain makes them shake in their hooves. They h…
题意:在一图中,每个点有俩个属性:现在牛的数量和雨棚大小(下雨时能容纳牛的数量),每个点之间有距离, 给出牛(速度一样)在顶点之间移动所需时间,问最少时间内所有牛都能避雨. 模型分析:多源点去多汇点(此题源点也可能是汇点(源汇同点)),所以我的方法是:建立超级源点和超级 汇点,超级源点连想所有点,容量为该店本来的牛数量,在把各点拆成如图(略丑),到汇点的容量分别为 避雨容纳量,点点之间容量可以无限大.folyd求任意两点的最短路后,二分最大时间建图,枚举求最大之最小即可. 未1A原因: 1:开始…
题目描述 FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain makes them shake in their hooves. They have decided to put a rain siren on the farm to let them know when rain is approaching. They intend to create a…
Description FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain makes them shake in their hooves. They have decided to put a rain siren on the farm to let them know when rain is approaching. They intend to cr…
/** 题目:poj2391 Ombrophobic Bovines 链接:http://poj.org/problem?id=2391 题意:有n块区域,第i块区域有ai头奶牛,以及一个可以容纳bi头奶牛的棚子.n块区域由m条可以容纳无数奶牛经过的双向通道相连,给定奶牛通过通道的时间. 问所有奶牛回到棚子需要的最短时间. 思路:...我好菜哦.没想到,看了blog才知道怎么做. 先用floyd求得两块区域相通最短时间. 将点x拆分成x,x'.源点s连接x,容量为x的奶牛数.x'连接汇点t容量为…
Ombrophobic Bovines Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20904   Accepted: 4494 Description FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain makes them shake in their hooves. They h…
Ombrophobic Bovines Description FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain makes them shake in their hooves. They have decided to put a rain siren on the farm to let them know when rain is approachin…
Ombrophobic Bovines Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16539 Accepted: 3605 Description FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain makes them shake in their hooves. They have…
Ombrophobic Bovines Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19066   Accepted: 4138 Description FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain makes them shake in their hooves. They h…
Ombrophobic Bovines Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Submit Status Description FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain makes them shake in their hooves.…
                     Ombrophobic Bovines Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18205   Accepted: 3960 Description FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain makes them shake in…
题目大意:在南极生活着一些企鹅,这些企鹅站在一些冰块上,现在要让这些企鹅都跳到同一个冰块上.但是企鹅有最大的跳跃距离,每只企鹅从冰块上跳走时会给冰块造成损害,因此企鹅跳离每个冰块都有次数限制.找出企鹅可以在哪些冰块上聚齐. 解题思路:(最大流 + 拆点)把每个冰块看做一个点,然后每个点拆分成两个相连的点,容量为最大的跳走次数.添加一个源点,源点到每个冰块代表的点连边,容量为开始冰块上的企鹅数目.枚举判断每个冰块是否满足条件. 代码: #include<iostream> #include<…
Ombrophobic Bovines Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 19359   Accepted: 4186 Description FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain makes them shake in their hooves. They h…
嗯,这是我上一篇文章说的那本宝典的第二题,我只想说,真TM是本宝典……做的我又痛苦又激动……(我感觉ACM的日常尽在这张表情中了) 题目链接:http://poj.org/problem?id=1637 Time Limit: 1000MS Memory Limit: 10000K Description The city executive board in Lund wants to construct a sightseeing tour by bus in Lund, so that t…