Pagini recente » Cod sursa (job #868913) | Cod sursa (job #2100794)
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define pb push_back
const ll mod = 1e9 + 7;
int n;
map <int, int> m;
vector <pair<ll, ll>> v;
ll x, y;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
if(a.first!=b.first) return (a.first<b.first); else return (a.second<b.second);
}
long double de(ll x1, ll x2, ll y1, ll y2){
return (long double)sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int32_t main(){
ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
ifstream fin("cmap.in");
ofstream fout("cmap.out");
//int x; cin>>x; cout<<fixed<<setprecision(11)<<(long double)sqrt(x);
fin>>n;
for(int i=0; i<n; i++){fin>>x>>y; v.pb(make_pair(x, y));}
sort(v.begin(), v.end(), sortbysec);
long double d=1000000000000;
for(int i=0; i<n-1; i++){
if(de(v[i].first, v[i+1].first, v[i].second, v[i+1].second)<d)
d=de(v[i].first, v[i+1].first, v[i].second, v[i+1].second);
}
for(int i=0; i<n-1; i++){
for(int j=i+1; j<n && (v[j].first-v[i].first < d); j++){
if(de(v[i].first, v[j].first, v[i].second, v[j].second)<d)
d=de(v[i].first, v[j].first, v[i].second, v[j].second);}
}
fout<<fixed<<setprecision(11)<<d;
}