Pagini recente » Cod sursa (job #259204) | Cod sursa (job #174221) | Cod sursa (job #420295) | Cod sursa (job #1192027) | Cod sursa (job #2117888)
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
class InParser {
private:
FILE *fin;
char *buff;
int sp;
char read_ch() {
++sp;
if (sp == 4096) {
sp = 0;
fread(buff, 1, 4096, fin);
}
return buff[sp];
}
public:
InParser(const char* nume) {
fin = fopen(nume, "r");
buff = new char[4096]();
sp = 4095;
}
InParser& operator >> (int &n) {
char c;
while (!isdigit(c = read_ch()) && c != '-');
int sgn = 1;
if (c == '-') {
n = 0;
sgn = -1;
} else {
n = c - '0';
}
while (isdigit(c = read_ch())) {
n = 10 * n + c - '0';
}
n *= sgn;
return *this;
}
InParser& operator >> (long long &n) {
char c;
n = 0;
while (!isdigit(c = read_ch()) && c != '-');
long long sgn = 1;
if (c == '-') {
n = 0;
sgn = -1;
} else {
n = c - '0';
}
while (isdigit(c = read_ch())) {
n = 10 * n + c - '0';
}
n *= sgn;
return *this;
}
};
struct point{int x, y;};
double dist(point a, point b){
return sqrt(1.0*(a.x - b.x) * (a.x - b.x) + 1.0*(a.y - b.y) * (a.y - b.y));
}
point v[MAXN];
bool cmp(point a, point b){if(a.x == b.x) return a.y < b.y; return a.x < b.x;}
int main(){
InParser f("cmap.in");
ofstream g("cmap.out");
int n;
f >> n;
for(int i = 0; i < n; ++i){
f >> v[i].x >> v[i].y;
}
sort(v, v + n, cmp);
double best = dist(v[0], v[1]);
for(int i = 0; i < n; ++i){
for(int j = i + 1; j < n && v[j].x - v[i].y < best; ++j){
best = min(best, dist(v[i], v[j]));
}
}
g << setprecision(10) << fixed << best;
return 0;
}