Cod sursa(job #977582)

Utilizator narcis_vsGemene Narcis - Gabriel narcis_vs Data 26 iulie 2013 10:20:23
Problema Cele mai apropiate puncte din plan Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 1.1 kb
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define In "cmap.in"
#define Out "cmap.out"
#define Nmax 100004
#define x first
#define y second

using namespace std;

pair<int, int > Point[Nmax];
int N;
long long sol;

inline void Read()
{
    ifstream in(In);
    in>>N;
    for(int i = 1 ;i<=N;++i)
        in>>Point[i].x>>Point[i].y;
    sort(Point+1,Point+N+1);
}

inline long long Dist(const int i,const int j)
{
    return 1LL*(Point[i].x-Point[j].x)*(Point[i].x-Point[j].x)+1LL*(Point[i].y-Point[j].y)*(Point[i].y-Point[j].y);
}

inline void Solve()
{
    sol = Dist(1,N);
    int i, j;
    long long x;
    for(i = 1;i < N; ++i)
        for(j = i+1 ;j <= N; ++j)
        {
            x = Dist(i,j);
            if(1LL*(Point[j].x-Point[i].x)*(Point[j].x-Point[i].x)>sol)
                break;
            sol = min(sol,x);
        }
}

inline void Write()
{
    ofstream out(Out);
    out<<fixed<<setprecision(6)<<sqrt(1.0*sol)<<"\n";
    out.close();
}

int main()
{
    Read();
    Solve();
    Write();
    return 0;
}