poj 3714 Raid 分治法求平面最近点对

2015-07-20 17:11:26 ? 作者: ? 浏览: 4

题意:

给平面上的n个点,求两点间的最短距离。

分析:

分治法,保存点用vector会tle...

代码:

//poj 3714
//sep9
#include 
  
   
#include 
   
     #include 
    
      using namespace std; const double INF=1e50; struct P { double x,y; int type; }p[240000],b[240000]; bool cmp_x(P a,P b) { return a.x
     
      =d) continue; for(int j=0;j
      
       =d) break; if(a[i].type==b[yn-1-j].type) continue; d=min(d,sqrt(dx*dx+dy*dy)); } b[yn++]=a[i]; } return d; } int main() { int cases; scanf("%d",&cases); while(cases--){ int i,n; scanf("%d",&n); for(i=0;i
       
        

-->

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: