hdoj--1533--Going Home(KM)】的更多相关文章

Tour Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 2549    Accepted Submission(s): 1257 Problem Description In the kingdom of Henryy, there are N (2 <= N <= 200) cities, with M (M <= 3000…
题意: 一个矩阵n*m,其中有k个房子和k个人,k个人分别必须走到任意一个房子中(匹配),但是权值就是长度(非欧拉距离),求匹配完的权之和. 思路: 建图方法是,首先将k个人和k个房子分别抽出来到集合X和Y中,计算两两之间的距离,X到Y有一条边,费用为正,容量为1:Y到X也有一条边,费用为负,容量为0(其实两条边就是相反的).添加一个源点0号到X集,添加一个汇点2*k+1号到Y集,这些费用都是0,容量都是1. 建完图就用正常的方法(EK+SPFA)来解决就行了.由于我想要让每次增广路只找到流为1…
Going Home Problem 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 f…
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…
Young naturalist Bill studies ants in school. His ants feed onplant-louses that live on apple trees. Each ant colony needsits own apple tree to feed itself.Bill has a map with coordinates of n ant colonies and napple trees. He knows that ants travel…
Assignment Problem Description Last year a terrible earthquake attacked Sichuan province. About 300,000 PLA soldiers attended the rescue, also ALPCs. Our mission is to solve difficulty problems to optimization the assignment of troops. The assignment…
奔小康赚大钱 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5865    Accepted Submission(s): 2589 Problem Description 传说在遥远的地方有一个非常富裕的村落,有一天,村长决定进行制度改革:重新分配房子. 这可是一件大事,关系到人民的住房问题啊.村里共有n间房间,刚好有n家老百姓,考…
Word Amalgamation 点我挑战题目 点我一起学习STL-MAP 题意分析 给出字典.之后给出一系列======乱序======单词,要求你查字典,如过这个乱序单词对用有多个有序单词可以输出,那么按照字典序将其输出. 若没有对应单词,输出NOT A VALID WORD. 可见这是一组组对应关系,可以用map来实现.map字典中first保存原本的单词(因为first按字典序),second保存原本单词排序后的单词.每次读入一个乱序单词后,sort遍历map并查找和second匹配的…
产生冠军 点我挑战题目 点我一起学习STL-MAP 题意分析 给出n组数据,代表a打败了b,让判断根据这n组数据是否能判断出来产生了冠军.一开始以为这道题很难,其实用map可以应付. 大原则,赢了的人置1,输了的人置0. 首先要知道胜利的人肯定不能输,①所以在map中输了的人置0,②并且如果这个人输过(也就是他的second已经为0了),即使是赢了的话,也不置为1.③最后遍历判断一下,map中是否只有1个一,如果是的话,就能产生冠军,否的话,就不能. 代码总览 /* Title:HDOJ.209…
Sorting Slides Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2831   Accepted: 1076 Description Professor Clumsey is going to give an important talk this afternoon. Unfortunately, he is not a very tidy person and has put all his transpa…