Cod sursa(job #977571)

Utilizator narcis_vsGemene Narcis - Gabriel narcis_vs Data 26 iulie 2013 09:59:53
Problema Cele mai apropiate puncte din plan Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 1.01 kb
#include <cstdio>
#include <algorithm>
#include <cmath>

#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()
{
    freopen(In,"r",stdin);
    freopen(Out,"w",stdout);
    scanf("%d",&N);
    for(int i = 1 ;i<=N;++i)
        scanf("%d %d",&Point[i].x,&Point[i].y);
    sort(Point+1,Point+N+1);
}

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

inline void Solve()
{
    sol = (1LL<<60)-1;
    int i, j;
    long long x;
    for(i = 1;i < N; ++i)
        for(j = i+1 ;j <= N; ++j)
        {
            x = Dist(i,j);
            if(x>=sol)
                break;
            sol = x;
        }
}

inline void Write()
{
    printf("%.6lf\n",sqrt(1.0*sol));
}

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