# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
356754 | hra_ved | Odašiljači (COCI20_odasiljaci) | C++17 | 82 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;
const int MAXN = 1e3+1;
int par[MAXN];
vector <pair <double, pair <int, int> > > vect;
int Find(int x);
bool UnionFind(int x, int y);
int main() {
int N; cin>>N;
for (unsigned i = 0; i < N; ++i) par[i] = i;
double Xs[N+1], Ys[N+1];
for (unsigned i=0; i<N; ++i) {
cin>>Xs[i]>>Ys[i];
for (int j = 0; j < i; j++) {
double pit = sqrt( pow((Xs[i]- Xs[j]), 2) + pow((Ys[i]- Ys[j]), 2)) ;
vect.push_back(make_pair(pit, make_pair(i, j)));
}
}
sort(vect.begin(), vect.end());
double rj = 0.0;
for (unsigned i=0; i<vect.size(); ++i) {
if (UnionFind(vect[i].second.first,vect[i].second.second)){
rj = vect[i].first / 2;
}
}
printf("%.9f\n", rj);
}
int Find(int x) {
return (x == par[x]) ? x : par[x] = Find(par[x]);
}
bool UnionFind(int x, int y) {
x = Find(x);
y = Find(y);
if (x != y) {par[x] = y; return true;}
return false;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |