Pagini recente » Cod sursa (job #1034599) | Cod sursa (job #2333297) | Cod sursa (job #2358373) | Cod sursa (job #807608) | Cod sursa (job #1466592)
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
using namespace std;
ofstream fout("cmap.out");
ifstream fin("cmap.in");
int n;
long double dist = (1LL << 62), d, x, y;
vector<pair<long long, long long>> v;
long double calc_dist(long long x1, long long y1, long long x2, long long y2)
{
return sqrt( (long double)((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) );
}
int main()
{
fin >> n;
for(int i=1; i<=n; i++) {
fin >> x >> y;
v.push_back(make_pair(x, y));
}
sort(v.begin(), v.end());
for(int i=0; i<n-1; i++)
for(int j=i+1; j<n && v[j].first - v[i].first < dist; j++)
if(abs(v[j].second - v[i].second) < dist) {
d = calc_dist(v[i].first, v[i].second, v[j].first, v[j].second);
dist = min(dist, d);
}
fout << fixed << setprecision(6) << dist << '\n';
return 0;
}