// author : anhtun_hi , nqg
// 25-26.12.2024
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define reset(h, v) memset(h, v, sizeof h)
#define Forv(i, a) for(auto& i : a)
#define For(i, a, b) for(int i = a; i <= b; ++i)
#define Ford(i, a, b) for(int i = a; i >= b; --i)
#define c_bit(i) __builtin_popcountll(i)
#define Bit(mask, i) ((mask >> i) & 1LL)
#define onbit(mask, i) ((mask) bitor (1LL << i))
#define offbit(mask, i) ((mask) &~ (1LL << i))
#define Log2(x) (63 - __builtin_clzll(x))
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
using db = long double;
using ull = unsigned long long;
namespace std {
template <typename T, int D>
struct _vector : public vector <_vector <T, D - 1>> {
static_assert(D >= 1, "Dimension must be positive!");
template <typename... Args>
_vector(int n = 0, Args... args) : vector <_vector <T, D - 1>> (n, _vector <T, D - 1> (args...)) {}
};
template <typename T> struct _vector <T, 1> : public vector <T> {
_vector(int n = 0, const T& val = T()) : vector <T> (n, val) {}
};
template <class A, class B> bool minimize(A &a, B b){return a > b ? a = b, true : false;}
template <class A, class B> bool maximize(A &a, B b){return a < b ? a = b, true : false;}
}
const int dx[] = {0, 0, +1, -1}, dy[] = {-1, +1, 0, 0}, LOG = 20, base = 311, inf = 1e9 + 5;
const int MAXN = 1e6 + 5;
const ll mod = 1e9 + 7;
const ll oo = 1e18;
const db esp = 1e-9;
#define int long long
int n;
struct disjoint_set{
int par[MAXN];
void init() {
For(i, 1, n) par[i] = -1;
}
int find(int u) {
return (par[u] < 0) ? u : (par[u] = find(par[u]));
}
bool merge(int u, int v) {
u = find(u), v = find(v);
if (u == v) return false;
if (par[u] > par[v]) swap(u, v);
par[u] += par[v], par[v] = u;
return true;
}
} dsu;
struct Point{
ll x, y; int id;
} a[MAXN];
bool cmp1(const Point &u, const Point &v){
return (u.x < v.x) || (u.x == v.x && u.y < v.y);
}
bool cmp2(const Point &u, const Point &v){
return (u.y < v.y) || (u.y == v.y && u.x < v.x);
}
bool cmp3(const Point &u, const Point &v){
return (u.x + u.y < v.x + v.y);
}
bool cmp4(const Point &u, const Point &v){
return (u.x - u.y < v.x - v.y);
}
db sqr(ll x){return x * x;}
db kc(const Point &u, const Point &v){
return sqrt(sqr(u.x-v.x) + sqr(u.y-v.y));
}
bool check(db val){
dsu.init();
sort(a + 1, a + n + 1, cmp1);
For(i, 2, n){
auto [ux, uy, u] = a[i];
auto [vx, vy, v] = a[i - 1];
if (kc(a[i], a[i - 1]) <= val) dsu.merge(u, v);
}
sort(a + 1, a + n + 1, cmp2);
For(i, 2, n){
auto [ux, uy, u] = a[i];
auto [vx, vy, v] = a[i - 1];
if (kc(a[i], a[i - 1]) <= val) dsu.merge(u, v);
}
sort(a + 1, a + n + 1, cmp3);
For(i, 2, n){
auto [ux, uy, u] = a[i];
auto [vx, vy, v] = a[i - 1];
if (kc(a[i], a[i - 1]) <= val) dsu.merge(u, v);
}
sort(a + 1, a + n + 1, cmp4);
For(i, 2, n){
auto [ux, uy, u] = a[i];
auto [vx, vy, v] = a[i - 1];
if (kc(a[i], a[i - 1]) <= val) dsu.merge(u, v);
}
int cnt = 0;
For(i, 1, n) cnt += (dsu.find(i) == i);
return (cnt == 1);
}
void Solve() {
cin >> n;
For(i, 1, n) {
cin >> a[i].x >> a[i].y;
a[i].id = i;
}
db l = 0, r = 1e12;
while (abs(r - l) > esp){
db mid = (l + r) / 2;
if (check(mid)) r = mid;
else l = mid;
}
db ans = r / 2;
cout << setprecision(7) << fixed << ans << '\n';
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
if(fopen("COCI20_odasiljaci.inp", "r")) {
freopen("COCI20_odasiljaci.inp", "r", stdin);
freopen("COCI20_odasiljaci.out", "w", stdout);
}
int t = 1;
// cin >> t;
while(t --) Solve();
return 0;
}
Compilation message (stderr)
odasiljaci.cpp: In function 'int main()':
odasiljaci.cpp:142:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
142 | freopen("COCI20_odasiljaci.inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
odasiljaci.cpp:143:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
143 | freopen("COCI20_odasiljaci.out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |