Pagini recente » Cod sursa (job #215115) | Cod sursa (job #3143188) | Cod sursa (job #2198805) | Cod sursa (job #1734917) | Cod sursa (job #1402102)
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>
#define INF (1LL<<62)
using namespace std;
int n,x,y;
long long minim = INF;
std::vector< std::pair<int,int> > a;
std::vector< int > b;
bool CMPX(std::pair<int,int> A,std::pair<int,int> B)
{
if(A.first<B.first)return true;
else if(A.first==B.first&&A.second<B.second)return true;
else return false;
}
bool CMPY(std::pair<int,int> A,std::pair<int,int> B)
{
if(A.second<B.second)return true;
else if(A.second==B.second&&A.first<B.first)return true;
else return false;
}
int main()
{
freopen("cmap.in","r",stdin);
freopen("cmap.out","w",stdout);
scanf("%d",&n);
for(int i=1;i<=n;++i)
{
scanf("%d %d",&x,&y);
a.push_back( std::make_pair(x,y) );
}
sort(a.begin(),a.end(),CMPX);
for(int i=0;i<a.size()-1;++i)
{
if(minim>(1LL*(a[i].first-a[i+1].first)*(a[i].first-a[i+1].first)+1LL*(a[i].second-a[i+1].second)*(a[i].second-a[i+1].second)))
{
minim = 1LL*(1LL*(a[i].first-a[i+1].first)*(a[i].first-a[i+1].first)+1LL*(a[i].second-a[i+1].second)*(a[i].second-a[i+1].second));
}
}
sort(a.begin(),a.end(),CMPY);
for(int i=0;i<a.size()-1;++i)
{
if(minim>(1LL*(a[i].first-a[i+1].first)*(a[i].first-a[i+1].first)+1LL*(a[i].second-a[i+1].second)*(a[i].second-a[i+1].second)))
{
minim = 1LL*(1LL*(a[i].first-a[i+1].first)*(a[i].first-a[i+1].first)+1LL*(a[i].second-a[i+1].second)*(a[i].second-a[i+1].second));
}
}
printf("%f",sqrt(minim));
return 0;
}