Spoj CLOPPAIR Solution
This is the solution for spoj Closest Point Pair #include<bits/stdc++.h> using namespace std; #define mn 9999999999.9 struct point { long double x,y; int index; }; point makepoint(double a,double b,int i) { point temp; temp.x=a;temp.y=b;temp.index=i; return temp; } double dist(point p1,point p2) { return sqrt((p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y)); } bool compareX(point a,point b) { return a.x < b.x; } bool compareY(point a,point b) { return a.y < b.y; } int indexa,indexb; double ans=999999999; double bruteforce(point p[],int n) { double d=mn; for( int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { double dtemp=dist(p[i],p[j]); if(dtemp<d) { d=dtemp; if(d < ans) { ans=d; indexa= p[i].index;