HDU1007 求最短距离的点对

#include
#include
#include
#include
using namespace std;
struct sys
{
	double x;
	double y;
};

sys num[100001],num1[100001],num2[100001];

bool cmpy(sys dot1,sys dot2)
{
	if(dot1.y==dot2.y) return dot1.xc) minx=c;
	return minx;
}
double getdistancex(sys dot1,sys dot2)
{
	double m=sqrt((dot1.x-dot2.x)*(dot1.x-dot2.x)+(dot1.y-dot2.y)*(dot1.y-dot2.y));
	return m;
}
double getdistancey(int low,int high)
{
	int count = high -low;
	double dis=0;
	if(count==0)  return 0;
	else if(count==1) {
		dis=getdistancex(num[low],num[high]);
		return dis;
	}
	else if(count==2)
	{
		double tem1= getdistancex(num[low],num[low+1]);
		double tem2= getdistancex(num[low+1],num[high]);
		double tem3= getdistancex(num[low],num[high]);
		dis=getmin(tem1,tem2,tem3); 
		return dis;
	}
	else 
	{
		double leftmin,rightmin;
		int mid=(high + low)/2;
		
		leftmin=getdistancey(low,mid);
		rightmin=getdistancey(mid+1,high);
		dis=min(leftmin,rightmin);
		
		int p=0;
		for(int i=low;i<=high;i++)
		{
			if(fabs(num[i].x-num[mid].x)>n&&n!=0)
	{
		for(int i=0;i>num[i].x>>num[i].y;
		}
		sort(num,num+n,cmpx);
		double min=getdistancey(0,n-1);
		cout<

你可能感兴趣的:(c&&c++)