POJ 3057 Evacuation 二分+最大流】的更多相关文章

Evacuation 题目连接: http://poj.org/problem?id=3057 Description Fires can be disastrous, especially when a fire breaks out in a room that is completely filled with people. Rooms usually have a couple of exits and emergency exits, but with everyone rushin…
题意:给定一个图,然后有几个门,每个人要出去,但是每个门每个秒只能出去一个,然后问你最少时间才能全部出去. 析:初一看,应该是像搜索,但是怎么保证每个人出去的时候都不冲突呢,毕竟每个门每次只能出一个人,并不好处理,既然这样,我们可以把每个门和时间的做一个二元组,然后去对应每个人,这样的话,就是成了二分图的匹配,就能做了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio&g…
题目大意 POJ链接 有一个\(X×Y\)的房间,X代表墙壁,D是门,.代表人.这个房间着火了,人要跑出去,但是每一个时间点只有一个人可以从门出去. 问最后一个人逃出去的最短时间,如果不能逃出去,输出impossible. 输入格式 第一行一个整数\(T\),表示有T组数据. 每组数据,第一行两个数字\(Y,X\),接下来有一个\(X×Y\)的图. 输出格式 \(T\)行答案,表示最后一个人逃出去的最短时间,如果不能逃出去,输出impossible. 数据范围 \(3\le Y\le X\le…
分析: 这是一个时间和门的二元组(t,d)和人p匹配的问题,当我们固定d0时,(t,d0)匹配的人数和t具有单调性. t增加看成是多增加了边就行了,所以bfs处理出p到每个d的最短时间,然后把(t,d)和p连边,按t从小到大 枚举点增广就好了.无解的情况只有一种,某个人无论如何都无法出去. /********************************************************* * --Sakura hirahira mai orite ochite-- * * au…
http://poj.org/problem?id=2175 Evacuation Plan Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3256   Accepted: 855   Special Judge Description The City has a number of municipal buildings and a number of fallout shelters that were build…
[题目链接] http://poj.org/problem?id=3057 [题目大意] 给出一个迷宫,D表示门,.表示人,X表示不可通行, 每个门每时间单位只允许一个人通过, 每个人移动一格的为一时间单位的时间, 问所有人逃离这个迷宫的最小时间 [题解] 我们首先对于每个门进行搜索,求出其到每个人的最短时间, 之后我们将每扇门对于人来拆点,分别为这个人第几秒通过这个门 将拆点后的门对所有人做一遍顺序二分图匹配 匹配最终完成的时间的门是其第几个拆点那么时间就是第几秒 [代码] #include…
题目 Fires can be disastrous, especially when a fire breaks out in a room that is completely filled with people. Rooms usually have a couple of exits and emergency exits, but with everyone rushing out at the same time, it may take a while for everyone…
题目给了一个满足最大流的残量网络,判断是否费用最小. 如果残量网络中存在费用负圈,那么不是最优,在这个圈上增广,增广1的流量就行了. 1.SPFA中某个点入队超过n次,说明存在负环,但是这个点不一定在负环上. 2.这个负环可能包括汇点t,所以构建残量网络的时候也要考虑防空洞到t上的容量. //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring…
题意:见挑战230页 #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <vector> #include <queue> #include <map> #include <algorithm> #include <set> using…
每个门每个时间只能出一个人,那就把每个门拆成多个,对应每个时间. 不断增加时间,然后增广,直到最大匹配. //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<iostream> #include<…