#include<cstdio>
#include<algorithm>
#include<cmath>
#define MAXN 10100
#define INF 0x3f3f3f3f
using namespace std;
struct node{
int x;
int y;
}point[MAXN];
bool cmpx(node a,node b){
return a.x < b.x;
}
bool cmpy(node c,node d){
return c.y < d.y;
}
double min(double w,double v){
return w <= v ? w : v;
}
double dis(node g,node p){
return sqrt( (g.x-p.x)*(g.x-p.x) + (g.y-p.y)*(g.y-p.y) );
}
double point_b(int left,int right){
double d=10000;
if(left == right) return d;
if(left+1 == right)
return dis(point[left], point[right]);
double d1 , d2 ;
int l = ( left + right ) / 2;
d1 = point_b(left, l );
d2 = point_b(l+1, right );
d = min(d1, d2 );
int i=left , j=right;
while(i < l && point[l].x - point[i].x >= d) i++;
while(j > l && point[j].x - point[l].x >= d) j--;
sort(point + i + 1, point + j + 1, c
平面分治(求最近点对)
最新推荐文章于 2023-08-27 15:48:36 发布