HDU 3523 Image copy detection 题目链接 题意:这题事实上题意读懂就简单了,说白了就是1-n放到1-n列,每列的值为每列上数字和该数字的差的绝对值,然后求总和最小 思路:就一KM最大匹配 代码: #include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <algorithm> using namespace std…
HDU 3718 Similarity 题目链接 题意:给定一个标准答案字符串,然后以下每一行给一个串.要求把字符一种相应一种,要求匹配尽量多 思路:显然的KM最大匹配问题,位置相应的字符连边权值+1 代码: #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; const int MAXNODE = 27; typede…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2853 题目大意:二分图匹配费用流.①最大匹配②最小原配变动 解题思路: 如果去掉第二个要求,那么就是裸KM. 然而加上第二个要求,那么就需要一种新的建图方式. 建图 对于输入矩阵,每一条边,cost扩大K倍($K=n+1$) 对于原配,每一条边cost在扩大K倍基础上+1 KM 统计cost时,直接把cost整除K,然后累加. 并且Hash一下原配边的变动情况. 扩大K倍的作用 准确来说,K倍是为了…
HDU 2853 Assignment 题目链接 题意:如今有N个部队和M个任务(M>=N),每一个部队完毕每一个任务有一点的效率,效率越高越好.可是部队已经安排了一定的计划,这时须要我们尽量用最小的变动,使得全部部队效率之和最大.求最小变动的数目和变动后和变动前效率之差. 思路:对于怎样保证改变最小,没思路,看了别人题解,恍然大悟,表示想法很机智 试想,假设能让原来那些匹配边,比其它匹配出来总和同样的权值还大,对结果又不影响,那就简单了,这个看似不能做到,事实上是能够做到的 数字最多选出50个…
KM算法详解+模板 - wenr - 博客园  http://www.cnblogs.com/wenruo/p/5264235.html #include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; #define MAXN 305 #define inf 65553566 int love[MAXN][MAXN]; /// 记…
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…
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2063 女生为X集合,男生为Y集合,求二分图最大匹配数即可. #include<cstdio> #include<iostream> #include<string.h> #include<algorithm> #include<math.h> #include<stdbool.h> #include<time.h> #incl…
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1068 本题求二分图最大独立点集.因为最大独立点集=顶点数-最大匹配数.所以转化为求最大匹配.因为没有给出男女,所以每个人都用了两遍,所以结果应该除以2. #include<cstdio> #include<iostream> #include<string.h> #include<algorithm> #include<math.h> #includ…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1045 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description Suppose that we have a square city with straight streets. A map of a city is a square board…
Assignment Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1068    Accepted Submission(s): 551 Problem Description Last year a terrible earthquake attacked Sichuan province. About 300,000 PLA s…
传送门: Assignment HDU - 2853 题意:题意直接那松神的题意了.给了你n个公司和m个任务,然后给你了每个公司处理每个任务的效率.然后他已经给你了每个公司的分配方案,让你求出最多能增大多少效率(即最大权值匹配减去原来的),然后问你至少要修改多少个关系(即修改多少条边) 思路:关键在于最小修改的老边,很巧妙的将老边和新边的权值做了修改,使得并且不改变km里面的顺序,可以说是很巧妙的了.之后就就直接跑km的板子就好了,挺好的题目,难在新旧边的处理. #include<cstdio>…
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…
http://acm.hdu.edu.cn/showproblem.php?pid=2444 The Accomodation of Students Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 2444 Description There are a group of students. Some of them may know…
题意:中文题目 思路:匈牙利算法解决二分图最大匹配问题. #include <bits/stdc++.h> using namespace std; ; int mapp[N][N]; //矩阵 int girl[N]; //记录该女已分配的男编号 int vis[N]; //标记是否已经尝试为其另分配 int n, a, b, k, m; int find(int x) { ; i<=m; i++) //扫描所有妹子 { if(mapp[x][i]&&!vis[i])…
题目:Warm up 2 题意:有横竖两种方式放着的多米诺骨牌,相同方向的不可能重叠,但是横放和竖放             的牌可能重叠.移走重叠的牌使剩下的牌最多. 分析:二分图匹配:最大独立集=顶点数-最大匹配数             横放的为一个点集,竖放的为一个点集. 代码: #include<cstdio> #include<iostream> #include<cstring> using namespace std; struct node { int…
<题目链接> 题目大意:有m个宾客,n把雨伞,预计时间t后将会下大雨,告诉你每个宾客的位置和速度,每把雨伞的位置,问你最多几个宾客能够拿到伞. 解题分析: 本题就是要我们求人与伞之间的最大匹配,但是数据量较大,匈牙利算法复杂度为$O(n*m)$,会超时,所以这里用的是复杂度为$O(sqrt(n)*m)$的HK算法. 当然,本题也可以用Dinic最大流来求解最大匹配,并且这种方法求得到最大匹配的时间复杂度也为$O(sqrt(n)*m)$ #include <bits/stdc++.h>…
The Accomodation of Students Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5225    Accepted Submission(s): 2374 Problem Description There are a group of students. Some of them may know each ot…
Game with Pearls Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1914    Accepted Submission(s): 671 Problem Description Tom and Jerry are playing a game with tubes and pearls. The rule of the…
题意难懂... 大意上说就是给m个排列P1,P2,P3...Pm,自己求个排列T使得T与Pi的各个数的绝对值差之和最小. 其实也就是二分最小匹配了.... #include <cstdlib> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <fstream> #include <iostream> #i…
1.男生女生一起坐过山车,每一排有两个座位,但是有个条件,就是每个女生必须找个男生做同伴一起(但是女生只愿意和某几个男生中的一个做同伴),求最多可以有多少对男女生组合坐上过山车. 2.二分图的最大匹配,女生作为X集合(左边),男生作为Y集合(右边) 3. 3.1匈牙利算法(邻接矩阵): /* 顶点编号从0开始的 邻接矩阵(匈牙利算法) 二分图匹配(匈牙利算法的DFS实现)(邻接矩阵形式) 初始化:g[][]两边顶点的划分情况 建立g[i][j]表示i->j的有向边就可以了,是左边向右边的匹配 g…
题意: M*N的矩阵,每个格子上是三个之一:*.o.#.                     (1 <= m, n <= 50) *:海洋,战船可以停在上面.      o:浮冰,战船不可以停在上面      #:冰山,战船不可以停在上面. 限制:两艘战船不能处于同一行或同一列,除非它们之间有冰山挡着. 问最多可以停多少艘战船. 思路: 和二分图最小点覆盖那道经典题很相似.不过不是求最小点覆盖. 对于每一行,如果连续的一段只能放一艘战船,则将这一段视为同一个点.则每一行都被分为若干个小段,…
#include <cstdio>#include <cmath>#include <algorithm>#include <iostream>#include <cstdlib>#include <string>#include <queue>#include <stack>#include <cstring>#define CL(a,b) memset(a,b,sizeof(a))#define…
There is a tree having N vertices. In the tree there are K monkeys (K <= N). A vertex can be occupied by at most one monkey. They want to remove some edges and leave minimum edges, but each monkey must be connected to at least one other monkey throug…
转自:http://blog.csdn.net/shahdza/article/details/7779324 [HDU]2255 奔小康赚大钱 模板题★1533 Going Home 模板题★2426 Interesting Housing Problem KM★3395 Special Fish KM★2282 Chocolate KM★2813 One fihgt one KM★1853 Cyclic Tour 最小费用圈覆盖★★3488 Tour 最小费用圈覆盖★★3435 A new…
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并查集======================================[HDU]1213   How Many Tables   基础并查集★1272   小希的迷宫   基础并查集★1325&&poj1308  Is It A Tree?   基础并查集★1856   More i…
=============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many Tables 基础并查集★ 1272 小希的迷宫 基础并查集★ 1325&&poj1308 Is It A Tree? 基础并查集★ 1856 More is better 基础并查集★ 1102 Constructing Roads 基础最小生成树★ 1232 畅通工程 基础并查集★ 123…
=============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many Tables 基础并查集★ 1272 小希的迷宫 基础并查集★ 1325&&poj1308 Is It A Tree? 基础并查集★ 1856 More is better 基础并查集★ 1102 Constructing Roads 基础最小生成树★ 1232 畅通工程 基础并查集★ 123…
Paper about Event Detection. #@author: gr #@date: 2014-03-15 #@email: forgerui@gmail.com 看一些相关的论文. 1. <Efficient Visual Event Detection using Volumetric Features> ICCV 2005 扩展2D box 特征到3D时空特征. 构建一个实时的检测器基于容积特征. 采用传统的兴趣点方法检测事件. 2. <ARMA-HMM: A New…
=============================以下是最小生成树+并查集====================================== [HDU] How Many Tables 基础并查集★ 小希的迷宫 基础并查集★ &&poj1308 Is It A Tree? 基础并查集★ More is better 基础并查集★ Constructing Roads 基础最小生成树★ 畅通工程 基础并查集★ 还是畅通工程 基础最小生成树★ 畅通工程 基础最小生成树★ 畅通…
This article come from HEREARS-L1: Learning Tuesday 10:30–12:30; Oral Session; Room: Leonard de Vinci 10:30  ARS-L1.1—GROUP STRUCTURED DIRTY DICTIONARY LEARNING FOR CLASSIFICATION Yuanming Suo, Minh Dao, Trac Tran, Johns Hopkins University, USA; Hojj…