huangriq

导航

2012年5月12日 #

poj 2400(最小权匹配)

摘要: 题意:给出雇主对雇员的满意度和雇员对雇主的满意度,分数越低代表评价越高,求给出最优匹配方案。当有多种最优匹配,全部输出!思路:典型的最小权匹配,km算法求解View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 #define inf 0x3f3f3f3f 7 #define N 111 8 int net[N][N],x[N],y[N],lx[N],ly[N],link 阅读全文

posted @ 2012-05-12 23:19 huangriq 阅读(314) 评论(0) 推荐(0)

poj 3613(最短路)

摘要: 题意:求解经过不多于某边数的最短路思路:矩阵连乘,乘的次数就是不多于某边数的最短路,题目给出的顶点需要映射处理View Code 1 #include<iostream> 2 #include<map> 3 #include<stdio.h> 4 #include<string.h> 5 using namespace std; 6 #define N 202 7 struct matrix{ 8 int f[N][N]; 9 matrix(){10 memset(f,0x3f,sizeof(f));11 }12 };13 int num;14 阅读全文

posted @ 2012-05-12 23:12 huangriq 阅读(219) 评论(0) 推荐(0)

poj 3522(生成树)

摘要: 题意:求解一个图中生成树最大边与最小边的最小差值思路:循环去掉小边求残图的最小生成树,求得最小生成树的最长边与最短边的最小差值就是答案,容易证明与最小边差值最小的生成树最大边必然在最小生成树中。View Code 1 #include<iostream> 2 #include<stdio.h> 3 #include<string.h> 4 #include<algorithm> 5 using namespace std; 6 #define inf 0x3f3f3f3f 7 #define N 110 8 #define M N*N 9 str 阅读全文

posted @ 2012-05-12 23:05 huangriq 阅读(180) 评论(0) 推荐(0)

poj 2446(二分匹配)

摘要: 题目:http://poj.org/problem?id=2446思路:对相邻的格子染上不同的颜色,并对没障碍物的相邻格子之间连边,建立一个二分图,求是否每个无障碍格子都能被匹配。View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<string.h> 4 #include<algorithm> 5 using namespace std; 6 #define M N*N 7 #define N 2020 8 struct edge{ 9 int to,next;10 }e[M] 阅读全文

posted @ 2012-05-12 22:51 huangriq 阅读(185) 评论(0) 推荐(0)

poj 1256(搜索)

摘要: B - BCrawling in process... Crawling failed Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1256DescriptionYou are to write a program that has to generate all possible words from a given set of letters. Example: Given the word "abc", your 阅读全文

posted @ 2012-05-12 22:38 huangriq 阅读(249) 评论(0) 推荐(0)