Pagini recente » Cod sursa (job #2937089) | Monitorul de evaluare | Cod sursa (job #2395231) | fara_nume | Cod sursa (job #1828888)
#include <algorithm>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <cstdlib>
using namespace std;
#ifndef ONLINE_JUDGE
#include <fstream>
ifstream cin ("cmap.in");
ofstream cout ("cmap.out");
#else
#include <iostream>
#endif // ONLINE_JUDGE
const int INF = 2000000000;
const int Nmax = 100000 + 10;
const double EPS = 0.000001;
using int64 = long long;
using PointTemp = pair <int64, int64>;
int N;
vector <PointTemp> Px, Py;
double res = 9999999999999;
void Input();
inline double Dist(const PointTemp&, const PointTemp&);
inline int64 Solve(int, int, vector <PointTemp>&, vector <PointTemp>&);
int main()
{
Input();
sort(Px.begin(), Px.end());
for (int i = 0; i < N; ++i)
for (int j = i+1, rng = 4; j < N && rng; ++j, --rng)
{
res = min(res, Dist(Px[i], Px[j]));
}
cout << fixed << setprecision(6) << res << '\n';
}
/*
for (int i = 0; i < N; ++i)
Py.push_back({Px[i].second, Px[i].first});
cout << Solve(0, N-1, Px, Py);
};
inline int64 Solve(int Left, int Right, vector <PointTemp>& X, vector <PointTemp>& Y)
{
cout << Left << ' ' << Right << '\n';
if (Right + Left + 1 < 2) return INF;
else
if (Right + Left + 1 == 2) {
if (Y[Left] > Y[Right])
swap(Y[Left, Y[Right]);
return Dist(Y[Left], Y[Right]);
}
int Mid = (Left + Right) / 2;
int64 Best = min(Solve(Left, Mid, X, Y), Solve(Mid+1, Right, X, Y));
return Best;
};
*/
void Input()
{
cin >> N;
for (int i = 1, x, y; i <= N; ++i)
{
cin >> x >> y;
Px.push_back({x, y});
}
};
inline double Dist(const PointTemp& A, const PointTemp& B)
{
return sqrt( 1LL * (B.second - A.second) * (B.second - A.second) + 1LL * (B.first - A.first) * (B.first - A.first) );
};