Pagini recente » Cod sursa (job #1052902) | Cod sursa (job #3152482) | Cod sursa (job #575683) | Cod sursa (job #949173) | Cod sursa (job #972172)
Cod sursa(job #972172)
#include <cmath>
#include <vector>
#include <limits>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iterator>
#include <algorithm>
namespace std
{
inline istream& operator>>(istream& in, pair<int, int>& x)
{
in >> x.first >> x.second;
return in;
}
}
using namespace std;
typedef pair<int, int> point;
typedef long long int lld;
vector<point> P;
inline lld dist(const point& x, const point& y)
{
return 1LL * (x.first - y.first) * (x.first - y.first) +
1LL * (x.second - y.second) * (x.second - y.second);
}
int main()
{
int N;
lld d = numeric_limits<lld>::max();
ifstream in("cmap.in");
ofstream out("cmap.out");
in >> N;
copy(istream_iterator<point>(in), istream_iterator<point>(), back_inserter(P));
sort(P.begin(), P.end());
for(int i = 0; i < N; ++i)
{
for(int j = i + 1; j < N; ++j)
{
if( 1LL * (P[j].first - P[i].first) * (P[j].first - P[i].first) > d) break;
d = min(d, dist(P[j], P[i]));
}
}
out << setprecision(6) << fixed << sqrt(d) << '\n';
}