Pagini recente » Cod sursa (job #1465137) | Cod sursa (job #2243407) | Cod sursa (job #2676864) | Cod sursa (job #1996320) | Cod sursa (job #2969202)
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <set>
using namespace std;
ifstream cin( "cmap.in" );
ofstream cout( "cmap.out" );
#define x first
#define y second
set<pair<int, int>> s;
long long dis( pair<int, int> A, pair<int, int> B ) {
return (long long)( A.x - B.x ) * ( A.x - B.x ) + (long long)( A.y - B.y ) * ( A.y - B.y );
}
const int MAX = 1e5 + 2;
pair<int, int> v[ MAX ];
int n;
int main()
{
cin >> n;
for( int i = 0; i < n; i++ )
cin >> v[ i ].x >> v[ i ].y;
sort( v, v + n, []( pair<int, int> A, pair<int, int> B ) {
return A.x < B.x;
} );
long long pp;
long long dMin = dis( v[ 0 ], v[ 1 ] );
for( int i = 0; i < n; i++ ) {
for( auto it = s.lower_bound( { v[ i ].y - dMin, 0 } ); it != s.end() && (*it).y <= v[ i ].y + dMin; it++ ) {
if( v[ i ].x - (*it).x > dMin )
s.erase( it );
else if( ( pp = dis( v[ i ], (*it) ) ) < dMin )
dMin = pp;
}
s.insert( v[ i ] );
}
cout << fixed << setprecision( 6 );
cout << (double)sqrt( dMin ) << '\n';
return 0;
}