POJ2195 Going Home【KM最小匹配】】的更多相关文章

题目链接:http://poj.org/problem?id=2195 Going Home Time Limit: 1000MS   Memory Limit: 65536K Total Submissions:27287   Accepted: 13601 Description On a grid map there are n little men and n houses. In each unit time, every little man can move one unit st…
Cyclic Tour Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/65535 K (Java/Others)Total Submission(s): 1197    Accepted Submission(s): 626 Problem Description There are N cities in our country, and M one-way roads connecting them. Now Li…
HDU 1533 Going Home 题目链接 题意:就是一个H要相应一个m,使得总曼哈顿距离最小 思路:KM完美匹配,因为是要最小.所以边权建负数来处理就可以 代码: #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; const int MAXNODE = 105; typedef int Type; const…
Mining Station on the Sea Problem Description The ocean is a treasure house of resources and the development of human society comes to depend more and more on it. In order to develop and utilize marine resources, it is necessary to build mining stati…
正则表达式的新手经常将贪婪匹配和最小匹配理解错误.默认情况下,Perl 的正则表达式是“贪婪地”,也就是说它们将尽可能多地匹配字符. 下面的脚本打印出“matched defgabcdef”,因为它尽可能多地匹配模式,直至结尾的‘g’. $data = 'abcdefgabcdefg';$data =~ /abc(.+)g/i;print "matched "; 要改变匹配特点,只须简单地在量词(加号[+]或星号[*])后面加一个问号(?)即可.在上面的程序中把模式改为在‘+’之后包含…
题目链接:https://vjudge.net/problem/POJ-2195 Going Home Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 24015   Accepted: 12054 Description On a grid map there are n little men and n houses. In each unit time, every little man can move one u…
题意:一个王国有N个城市,M条路,都是有向的,现在可以去旅游,不过走的路只能是环(至少也需要有两个城市),他们保证这些城市之间的路径都是有环构成的,现在至少需要走多少路. 分析:因为是有向图所以,而且走的是环所以每个城市都会进入一次并且出去一次,构成二分图,并且是完备匹配(完备匹配后肯定都是环了),现在只需要求出来这些匹配的最小值就行,可以把路径的值变为负数,然后求最大匹配值,最后的结果在变成相反数即可,注意路径可能有多条,输入的时候注意取最小的那个 **********************…
题目链接:http://poj.org/problem?id=2516 题目大意: 第一行是N,M,K 接下来N行:第i行有K个数字表示第i个卖场对K种商品的需求情况 接下来M行:第j行有K个数字表示第j个库房对K种商品的存货情况 接下来K个N*M的矩阵: 每个矩阵(i,j)表示第k种商品从第j个库房运到第i个卖场的运费(单价) 求满足所有需求的最小花费,如果不能全部满足输出-1. 解题思路: 拆点,对于第k种商品有: 把每个卖场的需求按件数拆成各个小点(比如需要x件就看做x个点) 把每个库房的…
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3399 题意: 给你一个数列a,和一个可变换顺序的序列b(数列长度≤25000). a增加一个单位代价为x,降低一个单位代价为y. 求a变为b的最小代价. 题解: 贪心. 将a,b分别从小到大排序,然后统计答案. 证明: 因为a,b均为升序,所以对于交换a[i]和a[j],有四种情况: 红色为a的走势,蓝色为b,绿色为花费.实线为交换之前,虚线为交换之后. (1)a,b不相交.交换前和交换…
[POJ 2400] Supervisor, Supervisee(KM求最小权匹配) Supervisor, Supervisee Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2538   Accepted: 719 Description Suppose some supervisors each get to hire a new person for their department. There are N…