12 2012 档案

摘要:题目:http://poj.org/problem?id=3020这个题主要是构图比较难,处理方法是把城市编号然后如果在上下左右四个方向存在城市的话,那么这两个城市就可以组成一条边,构成的图是一个无向图,DAG图的最小路径覆盖=节点数(n)-最大匹配数;无向图的最小路径覆盖=节点数(n)-最大匹配数/2;代码:View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 int map[405][405]; 6 int st[45 阅读全文
posted @ 2012-12-15 21:43 琳&leen 阅读(115) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=3041把X作为n1点集,y作为n2点集,x->y建立二分图,最小顶点覆盖。。View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 int n,k; 6 int map[505][505]; 7 int vis[505]; 8 int link[505]; 9 int find(int x)10 {11 int i;12 for(i=1;i<=n;i++ 阅读全文
posted @ 2012-12-15 20:10 琳&leen 阅读(138) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=1094代码:View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 int map[30][30]; 6 int de[30]; 7 int res[30];//存储结果 8 int n,m; 9 int topo()10 {11 int i,j;12 int d[30];13 int num,pos;14 int k=0,t=1;15 for(i=1;i<= 阅读全文
posted @ 2012-12-12 01:32 琳&leen 阅读(116) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=3026题意真的很难懂。。。题目大意:一个迷宫,'#'是墙,不可行走,‘ ‘是可行走的,现在题目是要求从s出发把所有的字母(‘A’)连起来的最短路径各个字母的边权用bfs可求:墙不可走,超出矩阵范围不可走,建立任意字母之间最短距离的图最后用prim就可以了注:用getchar会wa,不知道为什么。。。View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #define inf 3000 5 us 阅读全文
posted @ 2012-12-11 02:13 琳&leen 阅读(209) 评论(0) 推荐(0)
摘要:题目:http://poj.org/problem?id=1789大意:每个卡车都有自己的编号,由七位字母组成d(to,td) is the distance of the types指t0 和 td卡车编号字母不同的个数,即点t0和点td的权最好得衍生方案是是的总权值最小,即最小生成树用的primView Code #include <iostream>#include<cstdio>#include<cstring>#define inf 0x7fffffffusing namespace std;char str[2005][7];int map[20 阅读全文
posted @ 2012-12-03 20:46 琳&leen 阅读(147) 评论(0) 推荐(0)