# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
356497 | ivanpp | Odašiljači (COCI20_odasiljaci) | C++14 | 79 ms | 8664 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n;
int x[1005], y[1005];
int daddy[1005];
double ud(double x1, double x2, double y1, double y2) {
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
int find(int a) {
if (daddy[a] == a) return daddy[a];
return daddy[a] = find(daddy[a]);
}
bool junion(int x, int y) {
x = find(x);
y = find(y);
if (x != y) {
daddy[x] = y;
return true;
}
return false;
}
int main() {
cin >> n;
vector < pair < double, pair <int, int> > > uds;
for (int i = 0; i < n; i++) {
cin >> x[i] >> y[i];
for (int j = 0; j < i; j++) {
uds.push_back({ud(x[j], x[i], y[j], y[i]), {i, j}});
}
}
for (int i = 0; i < n; i++) {
daddy[i] = i;
}
sort(uds.begin(), uds.end());
double ans = 0.0;
for (int i = 0; i < uds.size(); i++) {
int xx = uds[i].second.first;
int yy = uds[i].second.second;
if (junion(xx, yy)) {
ans = uds[i].first / 2;
}
}
printf("%.9f \n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |