Cod sursa(job #1630318)

Utilizator gerd13David Gergely gerd13 Data 5 martie 2016 01:11:50
Problema Cele mai apropiate puncte din plan Scor 60
Compilator cpp Status done
Runda Arhiva educationala Marime 0.77 kb
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
const ll INF = 0x3f3f3f3f ;
struct unu {
    ll x, y;
} doi[100005];
ll dist(unu a, unu b) {
    return (b.x - a.x) * (b.x - a.x)
           + (b.y - a.y) * (b.y - a.y) ;
}
int N ;
bool cmp(unu a, unu b) {
    return a.x < b.x ;
}
int main() {
    ifstream f("cmap.in");
    freopen("cmap.out", "w", stdout) ;
    f>>N ;
    for(int i = 1 ; i <= N ; ++ i)
       f>>doi[i].x>>doi[i].y;

    sort(doi + 1, doi + N  + 1, cmp) ;
    ll big = INF ;
    for(int i = 1 ; i < N ; ++ i)
        for(int j = i + 1 ; j <= i + 7 && j <= N; ++ j)
            big = min(big, dist(doi[i], doi[j]));
    printf("%7lf", sqrt(big)) ;
    return 0;
}