曼哈顿最小生成树

#define _CRT_SECURE_NO_DEPRECATE
#include 
#include 
#include 
#define lowbit(x) (x&(-x))
using namespace std;
const int N = 100005;
struct Point{
	int x, y, id;//点坐标
	bool operator<(const Point p)const{
		return x != p.x ? x= 1; i -= lowbit(i))
		if (val= 0; i--){
			int pos = lower_bound(b, b + m, a[i]) - b + 1;   //BIT中从1开始
			int ans = ask(pos, m);
			if (ans != -1)
				addedge(p[i].id, p[ans].id, dist(i, ans));
			update(pos, p[i].x + p[i].y, i);
		}
	}
	//计算最小生成树【Krusal算法】,返回花费
	int cost = 0;
	sort(e, e + tot);
	for (int i = 0; i

你可能感兴趣的:(算法模板)