- 博客(0)
- 资源 (2)
- 收藏
- 关注
ACM算法集锦
数据结构相关算法,绝对有用
比如
kurXX最小生成树
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
#define M 501
#define LIM 20000000
struct edg{
int u,v;
int w;
}all_e[M*M/2];
bool operator < (const edg &a,const edg &b){
return a.w<b.w;
}
int set[M];
inline bool uni(int set[],int a,int b){
int ac=0,a2=a,b2=b,bc=0;
while(set[a]!=0) {a=set[a];ac++;}
if(a2!=a) set[a2]=a;
while(set[b]!=0) {b=set[b];bc++;}
if(b2!=b) set[b2]=b;
if(a==b) return false;
if(ac<bc) set[a]=b;
else set[b]=a;
return true;
}
2014-12-24
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人