08 2012 档案

摘要:证明最大匹配=最小点集覆盖http://blog.csdn.net/wmn_wmn/article/details/7275648Sample Input4 4*.*..******...*.Sample Output4题意:有一块地,由于下雨,使部分面积出现泥泞,但牛只吃干净的草,现在想把出现泥泞的地方用木板铺盖上,这样牛的蹄子就不会因为踩到泥泞的地方弄脏草地上的草;一个n行m列的矩阵,"*“代表泥泞的土地,”.“代表草地,求最少覆盖的木板个数。注意:木板宽始终为1,长不限制;求最小覆盖=最大匹配;解析:这里我用0表示草地,则按行来铺木板,最有个数是51 0 2 0 0 3 3 3 阅读全文
posted @ 2012-08-03 20:35 zlyblog 阅读(233) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2255[KM算法的几种转化]KM算法是求最大权完备匹配,如果要求最小权完备匹配怎么办?方法很简单,只需将所有的边权值取其相反数,求最大权完备匹配,匹配的值再取相反数即可。KM算法的运行要求是必须存在一个完备匹配,如果求一个最大权匹配(不一定完备)该如何办?依然很简单,把不存在的边权值赋为0。KM算法求得的最大权匹配是边权值和最大,如果我想要边权之积最大,又怎样转化?还是不难办到,每条边权取自然对数,然后求最大和权匹配,求得的结果a再算出e^a就是最大积匹配。至于精度问题则没有更好的办法了。(详细关于 阅读全文
posted @ 2012-08-03 20:08 zlyblog 阅读(279) 评论(0) 推荐(0)
摘要:InputThere will be multiple input cases.Each test case begins with two integers n, k. n is the number of rows and columns of the balloons (1 <= n <= 100), and k is the times that ginving to each student(0 < k <= n).Follow a matrix A of n*n, where Aij denote the color of the ballon in the 阅读全文
posted @ 2012-08-02 15:37 zlyblog 阅读(207) 评论(0) 推荐(0)
摘要:View Code 1 #include<stdio.h> 2 #include<string.h> 3 int t,n,m,num,map[1001][1001],a[1001],b[1001]; 4 int dfs(int x) 5 { 6 int i; 7 for(i=1;i<=m;i++) 8 { 9 if(map[x][i]&&b[i]==0)//对其进行覆盖10 {11 b[i]=1;12 if(a[i]==-1||dfs(a[i]))13 {14 ... 阅读全文
posted @ 2012-08-02 14:45 zlyblog 阅读(363) 评论(0) 推荐(0)
摘要:并查集,欧拉回路View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 int n,len1; 5 char s[1005]; 6 int a[30],b[30]; 7 int set[30]; 8 int find(int x) 9 {10 if(x!=set[x])11 set[x]=find(set[x]);12 return set[x];13 }14 void met()15 {16 int i,x,y;17 for(i=1;i<=n;i++)... 阅读全文
posted @ 2012-08-01 17:13 zlyblog 阅读(195) 评论(0) 推荐(0)
摘要:这个题主要有个小细节就是n=0时,应该输出1;这里给出两种方法:View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #define N 10000005 5 int set[N],b[100005]; 6 int a[100005]; 7 int s[100005]; 8 int find(int x) 9 {10 if(x==set[x])11 return x;12 else13 set[x]=find(set[x]);14 }15 int ma... 阅读全文
posted @ 2012-08-01 15:16 zlyblog 阅读(200) 评论(0) 推荐(0)
摘要:跟小希的迷宫有些相似。但却不知道为什么那些做法放这里就超时了。……View Code 1 2 #include <iostream> 3 #include <string.h> 4 #include <string> 5 #include <cstdio> 6 using namespace std; 7 int leftt[10005],rightt[10005],father[10005]; 8 int find(int x){ 9 if(father[x]==-1)10 return x;11 return find(father[x]); 阅读全文
posted @ 2012-08-01 10:58 zlyblog 阅读(207) 评论(0) 推荐(0)