摘要:
题意:有N个客户,M个仓库,和K种货物。已知每个客户需要每种货物的数量,每个仓库存储每种货物的数量,每个仓库运输各种货物去各个客户的单位费用。判断所有的仓库能否满足所有客户的需求,如果可以,求出最少的运输总费用。分析:首先判断每个仓库的库存是否满足N个客户的需要,在这个条件下,因为有K种货物,而K种货物又是从不同的仓库发出的,所以对于每一种货物,我们可以设想起其为一种费用,对每种货物进行一次 最小费用最大流即可。View Code #include <cstdio>#include <cstring>#include <iostream>#include & 阅读全文
posted @ 2012-07-04 18:33
lenohoo
阅读(138)
评论(0)
推荐(0)
摘要:
题意:给出20个国家的连接情况,然后求出连接2个目标国家的最少边数。算法:转化为最短路问题。将每条边的权值设为1,“最少边数”即等价为“最短路”View Code #include <cstdio>#include <cstring>#include <iostream>using namespace std;#define re1(i,n) for(int i=1;i<=n;i++)const int maxn = 21;int map[maxn][maxn];int main() { int n , m; int cas = 1; while(~s 阅读全文
posted @ 2012-07-04 04:28
lenohoo
阅读(186)
评论(0)
推荐(0)
摘要:
题意:有一迷宫,求从入口到出口的最短路、左优先最短路、右优先最短路。算法:bfs+dfsView Code #include <cstdio>#include <cstring>#include <iostream>#include <queue>using namespace std;const int maxn = 50;bool vis[maxn][maxn];char map[maxn][maxn];int ldir[4][2] = { {-1,0},{0,1},{1,0},{0,-1} };int rdir[4][2] = { {-1, 阅读全文
posted @ 2012-07-04 02:54
lenohoo
阅读(150)
评论(0)
推荐(0)
浙公网安备 33010602011771号