Pagini recente » Cod sursa (job #2505703) | Cod sursa (job #2397692) | Cod sursa (job #2299325) | Cod sursa (job #194127) | Cod sursa (job #2117871)
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
class Reader {
public:
Reader(const string& filename):
m_stream(filename),
m_pos(kBufferSize - 1),
m_buffer(new char[kBufferSize]) {
next();
}
Reader& operator>>(int& value) {
value = 0;
while (current() < '0' || current() > '9')
next();
while (current() >= '0' && current() <= '9') {
value = value * 10 + current() - '0';
next();
}
return *this;
}
private:
const int kBufferSize = 32768;
char current() {
return m_buffer[m_pos];
}
void next() {
if (!(++m_pos != kBufferSize)) {
m_stream.read(m_buffer.get(), kBufferSize);
m_pos = 0;
}
}
ifstream m_stream;
int m_pos;
unique_ptr<char[]> m_buffer;
};
pair< int, int > v[MAXN];
double dist(pair< int, int >& a, pair< int, int >& b){
return sqrt(1.0*(a.first - b.first) * (a.first - b.first) + 1.0*(a.second - b.second) * (a.second - b.second));
}
Reader f("cmap.in");
ofstream g("cmap.out");
int main(){
int n;
f >> n;
for(int i = 0; i < n; ++i){
f >> v[i].first >> v[i].second;
}
sort(v, v + n);
double best = dist(v[0], v[1]);
for(int i = 0; i < n; ++i){
for(int j = i + 1; j < n && v[j].first - v[i].first < best; ++j){
best = min(best, dist(v[i], v[j]));
}
}
g << setprecision(10) << fixed << best;
return 0;
}