Description Alice, a charming girl, have been dreaming of being a movie star for long. Her chances will come now, for several filmmaking companies invite her to play the chief role in their new films. Unfortunately, all these companies will start mak…
poj 1698  Alice's Chance 题目地址: http://poj.org/problem?id=1698 题意: 演员Alice ,面对n场电影,每场电影拍摄持续w周,每周特定几天拍摄,每场电影需要Alice到场的天数为d. 请问Alice是否可以参与所有的电影拍摄. 最近在学习最大流的算法. (1), 最大流真的是一种神奇的算法,最大的亮点是最大流的可回溯性,其可回溯性体现在反向边的提出. (2), 最大流的应用也是非常灵活的,其中一个体现在如何构建流量网络,本题采用逆向思维…
Description Cows are such finicky eaters. Each cow has a preference for certain foods and drinks, and she will consume no others. Farmer John has cooked fabulous meals for his cows, but he forgot to check his menu against their preferences. Although…
题目:给出n部电影的可以在周几拍摄.总天数.期限,问能不能把n部电影接下来. 分析: 对于每部电影连上源点,流量为总天数. 对于每一天建立一个点,连上汇点,流量为为1. 对于每部电影,如果可以在该天拍摄,则连上一条流量为1的边. 跑一次最大流... #include <set> #include <map> #include <list> #include <cmath> #include <queue> #include <stack&g…
Description On a grid map there are n little men and n houses. In each unit time, every little man can move one unit step, either horizontally, or vertically, to an adjacent point. For each little man, you need to pay a $1 travel fee for every step h…
Description Dearboy, a goods victualer, now comes to a big problem, and he needs your help. In his sale area there are N shopkeepers (marked from 1 to N) which stocks goods from him.Dearboy has M supply places (marked from 1 to M), each provides K di…
Description Jamie is a very popular girl and has quite a lot of friends, so she always keeps a very long contact list in her cell phone. The contact list has become so long that it often takes a long time for her to browse through the whole list to f…
题目:Alice 要拍电影,每一天只能参与一部电影的拍摄,每一部电影只能在 Wi 周之内的指定的日子拍摄,总共需要花 Di 天时间,求能否拍完所有电影. 典型的二分图多重匹配,这里用了最大流的 dinic 算法.构图:源点向每部电影流容量为 Di 的边,电影向允许的日期流容量为 1 的边,每一天向汇点流容量为 1 的边.跑一次最大流,如果最大流等于 ∑D,那么就可以. 一开始用了多路增广忘了把流量为零的 d 设为 -1--悲剧--TLE 了. 代码: #include <cstdio> #in…
POJ 1698 Alice's Chance 题目链接 题意:拍n部电影.每部电影要在前w星期完毕,而且一周仅仅有一些天是能够拍的,每部电影有个须要的总时间,问能否拍完电影 思路:源点向每部电影连边,容量为d,然后每部电影相应能拍的那天连边,因为每天容量限制是1.所以进行拆点,然后连向汇点就可以 代码: #include <cstdio> #include <cstring> #include <queue> #include <algorithm> us…
将星期拆点,符合条件的连边,最后统计汇点流量是否满即可了,注意结点编号. #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> #include<set> #include<map> #include<queue> #include<vector> #include<s…