# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
332528 | morato | Odašiljači (COCI20_odasiljaci) | C++17 | 351 ms | 620 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* author: morato
* created: 02.12.2020 16:14:43
**/
#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
double X[N], Y[N];
int p[N], rnk[N];
int n;
int find(int v) {
return p[v] == v ? v : p[v] = find(p[v]);
}
void merge(int a, int b) {
int x = find(a);
int y = find(b);
if (x != y) {
if (rnk[x] > rnk[y]) swap(x, y);
p[x] = y;
if (rnk[x] == rnk[y]) rnk[y]++;
}
}
double dist(int i, int j) {
return sqrt((X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]));
}
bool check(double radius) {
for (int i = 1; i <= n; i++) {
p[i] = i;
rnk[i] = 0;
}
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
if (dist(i, j) <= 2 * radius) {
merge(i, j);
}
}
}
set<int> st;
for (int i = 1; i <= n; i++) {
st.insert(find(i));
}
return (int) st.size() == 1;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> X[i] >> Y[i];
}
double l = 0.0, r = 1e10, best = 0.0;
for (int i = 0; i < 100; i++) {
double m = (l + r) / 2.0;
if (check(m)) {
best = m;
r = m;
} else {
l = m;
}
}
cout << setprecision(10) << fixed << best << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |