
ACM水题之路—图论
a342374071
这个作者很懒,什么都没留下…
展开
-
HDU 1043 eight 八数码
其实最重要的就是判重这个关卡,说到底用的也是一个哈希的算法,利用当前这个数的逆序数来构建的。//ashione 2011-3-31#include#include#includeusing namespace std;#define N 10#define MAX 362881 //最多可能有9!个排列int fac[]={1,1,2,6,24,120,720,5040,40320,362880};//康托展开数列bool visited[MAX]; string rou原创 2011-05-26 14:08:00 · 1959 阅读 · 1 评论 -
HDU 1878 欧拉回路
<br />//ashione 2011-6-1 ,欧拉回路检测#include<iostream>#include<cstring>#include<cstdio>using namespace std;#define SetMax 1001int in[SetMax],out[SetMax],map[SetMax][SetMax];bool mark[SetMax];void init(int n){ memset(mark,false,(n+1)*sizeof(bo原创 2011-06-01 22:05:00 · 794 阅读 · 0 评论 -
HDU 1863 畅通工程(最小生成树prim算法)
#include#include#includeusing namespace std;#define M 101int map[M][M],v,arc;void init(){ //用-1标记距离为无穷大。 memset(map,-1,sizeof(map)); int from,to,weight; while(arc--){ cin>>from>>to>>weight; if(map[from][to]weight) map[from][t原创 2011-05-31 17:25:00 · 688 阅读 · 0 评论 -
HDU 1879 继续畅通工程(最小生成树 Kruskal算法)
#include#include#includeusing namespace std;#define M 101typedef struct egde{ int e,s,weight; bool build;}egde;egde info[M*M/2];int c[M],n,num;bool cmp(const egde a,const egde b){ if(a.build!=b.build) return a.build原创 2011-05-31 20:13:00 · 1020 阅读 · 0 评论 -
HDU 1116 Play on Words(并查集,欧拉回路)
<br />//ashione 2011-6-1 ,并查集,欧拉回路检测#include<iostream>#include<cstring>using namespace std;#define SetMax 27#define StringMax 1001int set[SetMax],in[SetMax],out[SetMax],point[SetMax];char temp[StringMax];bool mark[SetMax],falg;int find(in原创 2011-06-01 21:16:00 · 577 阅读 · 0 评论 -
Hdu 1532 网络流模版
#include#includeusing namespace std;#define INF 1<<30#define M 201#define Min(a,b) (a)<(b)?(a):(b)int cap[M][M],flow[M][M],n,m; //cap原创 2011-08-14 10:06:12 · 488 阅读 · 0 评论 -
zju 1525 Air Raid(最小路径覆盖)
#include#includeusing namespace std;#define MAX_N 121//有向图最小路径覆盖=|V| - 最大匹配数; 无向图最小路径覆盖=|V| - 最大匹配数/2。bool map[MAX_N][MAX_N],use[MAX_N]原创 2011-08-14 16:32:45 · 942 阅读 · 8 评论 -
hdu 1068 boys and girls(最大独立点集 ,匈牙利算法)
最大独立点集=最小覆盖路径= 顶点数 - 最大二分匹配/2 (!)题意是求最少有几组出去,能匹配则匹配,不能的就是自己单独一组。这个是匈牙利算法,属于模版题。#include #include //using namespace std;#de原创 2011-08-18 22:14:36 · 1329 阅读 · 1 评论 -
zju/zoj 1140 Courses
#include#include#includeusing namespace std;#define M 505int n,p,m,a,path[M];bool map[M][M],use[M];void init(){ memset(map,false原创 2011-08-20 18:43:04 · 721 阅读 · 0 评论