[题意]: 有N个人,M个仓库,每个人需要物品,个数都等于共同的K,仓库中有对应的K件物品的数量,随后给K个N*M矩阵(小写k, n, m表示K,N,M对应的子集),表明m个仓库到第n个人的位置运送k物品的花费,求 满足所有人的订单要求所需要的花费,如果不能满足所有人则输出-1 [思路]: 我的思路是建立源点sp,汇点tp, 把仓库和人所在的点都进行拆分,对每个仓库拆分成K个点,可以想象成一个大仓库由K个小仓库组成,每个小仓库只发放第k种物品,每个人也分成K个点,每个点接受一种k物品,sp与仓库…
http://poj.org/problem?id=2516 #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #define maxn 110 using namespace std; int need[maxn][maxn]; int sup[maxn][maxn]; int cost[maxn][maxn][maxn]; int cap[maxn][maxn];…
poj 2049(二分+spfa判负环) 给你一堆字符串,若字符串x的后两个字符和y的前两个字符相连,那么x可向y连边.问字符串环的平均最小值是多少.1 ≤ n ≤ 100000,有多组数据. 首先根据套路,二分是显然的.然后跑一下spfa判断正环就行了. 然而我被no solution坑了十次提交.. #include <cctype> #include <cstdio> #include <cstring> using namespace std; const in…
题目: 给出n*kk的矩阵,格子a[i][k]表示第i个客户需要第k种货物a[i][k]单位. 给出m*kk的矩阵,格子b[j][k]表示第j个供应商可以提供第k种货物b[j][k]单位. 再给出k个n*m的矩阵,格子c[k][i][j]表示第k种货物由j供应商提供给客户i的话,每单位运费为c[k][i][j]. 问最小费用. 分析: 刚开始时,虽然考虑到每种货物其实是不相关的,但是想到在跑费用流时应该没多大影响,所以直接建图,跑最小费用流,TLE了... 后来对于每种货物单独来考虑,即建图之后…
Minimum Cost Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 13511   Accepted: 4628 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)…
题目链接:http://poj.org/problem?id=2195 Going Home Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 21530   Accepted: 10871 Description On a grid map there are n little men and n houses. In each unit time, every little man can move one unit s…
题目链接:http://poj.org/problem?id=3259 Wormholes Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 44090   Accepted: 16203 Description While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is ver…
题目链接:http://poj.org/problem?id=2942 思路:我们对于那些相互不憎恨的骑士连边,将每次参加会议的所有人(不一定是整个骑士团,只需人数>=3且为奇数)看做一个点双联通分量,那么每个点都至少有两个点与他相邻.即需要保证双联通分量中存在奇圈.至于如何判奇圈,这里有一个性质:一个图是二分图当且仅当图中不存在奇圈.至于如何判断一个图是否是二分图,可以采用交替染色的方式判断.http://blog.csdn.net/lyy289065406/article/details/6…
When FJ's friends visit him on the farm, he likes to show them around. His farm comprises N (1 <= N <= 1000) fields numbered 1..N, the first of which contains his house and the Nth of which contains the big barn. A total M (1 <= M <= 10000) pa…
Wormholes Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 42366 Accepted: 15560 传送门 Description While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way p…