摘要: #include<stdio.h>#define N 1000#include<string.h>int result[N],map[N][N],vis[N],n,m;int dfs(int x){ int i; for(i=1;i<=m;i++) { if(!vis[i]&&map[x][i]) { vis[i]=1; if(result[i]==0||dfs(result[i])) { result[i]=x; retu... 阅读全文
posted @ 2012-03-08 20:02 Szz 阅读(182) 评论(0) 推荐(0)
摘要: 匈牙利算法的基本知识:百度百科:http://baike.baidu.com/view/501092.htm维基百科: 这里面有邻接矩阵的模拟图http://en.wikipedia.org/wiki/Hungarian_algorithm二分图定理总结http://www.cnblogs.com/jffifa/archive/2011/12/26/2302480.html题目: 大部分属于模板题,就不贴代码了http://acm.hdu.edu.cn/showproblem.php?pid=2119http://acm.hdu.edu.cn/showproblem.php?pid=1083h 阅读全文
posted @ 2012-03-07 20:11 Szz 阅读(292) 评论(0) 推荐(0)
摘要: poj 3020 Antenna Placement(二分图+最小路径覆盖)?马虎了一下,少些了个=号,错了N 遍http://poj.org/problem?id=3020#include<stdio.h>#include<string.h>#define N 1000int a,h,w;char str[N][N];int map[N][N],vis[N],result[N];int bian(int x,int y){ if(x>=0&&x<=h&&y>=0&&y<=w) { if(str[x 阅读全文
posted @ 2012-03-07 20:09 Szz 阅读(146) 评论(0) 推荐(0)
摘要: 马虎了一下,少些了个=号,错了N 遍http://poj.org/problem?id=3020#include<stdio.h>#include<string.h>#define N 1000int a,h,w;char str[N][N];int map[N][N],vis[N],result[N];int bian(int x,int y){ if(x>=0&&x<=h&&y>=0&&y<=w) { if(str[x][y]=='*') { return x*w+y; } re 阅读全文
posted @ 2012-03-07 20:08 Szz 阅读(137) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=2049/* 我认为这是一道非常好的搜索题,第一次使用到了优先队列,(是更新的距离最短),0代表空 1代表 们 inf 代表wall 用h[][]存储行的信息,l[][],存储列的信息{学到的新知识,对于这种一方格作为点的 图 用两个二维图分别存储变得信息}*/#include<cstdio>#include<cstring>#include<queue>using namespace std;#define maxn 250#define inf 99999999struct node{ int x; i 阅读全文
posted @ 2012-03-06 20:47 Szz 阅读(481) 评论(0) 推荐(0)
摘要: 一直很晕,用c++16Ms过,用G++WA!!!!!!!!http://poj.org/problem?id=3278#include<stdio.h>#include<string.h>#define N 100000int n,k,vis[N];struct node{ int step; int num;}p[N*10];int bfs(){ memset(vis,0,sizeof(vis)); int head=0,tail=0; p[head].num=n; p[head].step=0; vis[n]=1; tail++; w... 阅读全文
posted @ 2012-03-03 20:28 Szz 阅读(148) 评论(0) 推荐(0)
摘要: #include<stdio.h>#define max 999999#define N 1000int dis[N],vis[N],map[N][N];int sum,n;void prim(int x){ int i,j,k; for(i=0;i<n;i++) { dis[i]=map[x][i]; vis[i]=0; } vis[x]=1; dis[x]=0; for(i=1;i<n;i++) { int min=max; for(j=0;j<n;j++) { ... 阅读全文
posted @ 2012-03-03 16:32 Szz 阅读(150) 评论(0) 推荐(0)
摘要: #include<stdio.h>#define max 999999#define N 1000int dis[N],vis[N],map[N][N];int sum,n;void prim(int x){ int i,j,k; for(i=0;i<n;i++) { dis[i]=map[x][i]; vis[i]=0; } vis[x]=1; dis[x]=0; for(i=1;i<n;i++) { int min=max; for(j=0;j<n;j++) { ... 阅读全文
posted @ 2012-03-03 16:32 Szz 阅读(157) 评论(0) 推荐(0)
摘要: #include<cstdio>#include<stdlib.h>#define N 1000struct node{ int x,y,w;}p[N*N];int f[N];int cmp( const void *a ,const void *b){return (*(node *)a).w > (*(node *)b).w ? 1 : -1;}int find(int x){ if(x!=f[x])f[x]=find(f[x]); return f[x];}int main(){ int t,i,j,k,n,b; scanf("%d",& 阅读全文
posted @ 2012-03-03 16:31 Szz 阅读(167) 评论(0) 推荐(0)
摘要: http://poj.org/problem?id=2240floyd 的变形 题意 有n个货币,他们的交换情况m个例如:3USDollarBritishPoundFrenchFranc3USDollar 0.5 BritishPoundBritishPound 10.0 FrenchFrancFrenchFranc 0.21 USDollar求出 是否存个一个增长的货币回路#include<iostream>#include<string>#include<string.h>#include<stdio.h>const double eps=1 阅读全文
posted @ 2012-03-03 15:21 Szz 阅读(151) 评论(0) 推荐(0)