# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
356513 | PotatoOnABus | Odašiljači (COCI20_odasiljaci) | C++14 | 88 ms | 8684 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>
#include<iostream>
#include<vector>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
typedef long long ll;
typedef pair<double, double> par;
typedef pair<double, pair<int, int>> connec;
const int maxn = INT_MAX;
vector<par> points;
vector<connec> vert;
double dist(pair <double, double> x, pair<double, double> y) {
return sqrt((x.first - y.first) * (x.first - y.first) + (x.second - y.second) * (x.second - y.second));
}
vector<int> parovi;
int find(int x) {
if (x == parovi[x]) return parovi[x];
return parovi[x] = find(parovi[x]);
}
bool _union(int x, int y) {
x = find(x);
y = find(y);
if (x != y) {
parovi[x] = y;
return true;
}
return false;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
par tmp;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> tmp.first >> tmp.second;
points.push_back(tmp);
}
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
if (i == j) continue;
connec temp;
temp.second.first = i;
temp.second.second = j;
temp.first = dist(points[i], points[j]);
vert.push_back(temp);
}
}
sort(vert.begin(), vert.end());
for (int i = 0; i < n; i++) parovi.push_back(i);
double ans = 0.0;
for (int i = 0; i < vert.size(); i++) {
if (_union(vert[i].second.first, vert[i].second.second)) ans = vert[i].first / 2;
}
printf("%.9f \n", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |