# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
376236 | lyc | Odašiljači (COCI20_odasiljaci) | C++14 | 57 ms | 8172 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;
#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)
typedef long long ll;
typedef tuple<ll,int,int> edge;
#define SQ(x) (((ll)x)*(x))
const int mxN = 1005;
const int mxE = 500005;
int N, X[mxN], Y[mxN];
edge el[mxE];
struct DSU {
int *rt, *sz, comp;
DSU(int n) {
rt = new int[n] - 1;
sz = new int[n] - 1;
comp = n;
FOR(i,1,n){
rt[i] = i;
sz[i] = 1;
}
}
int finds(int i) { return (rt[i] == i) ? i : (rt[i] = finds(rt[i])); }
bool unions(int i, int j) {
int x = finds(i), y = finds(j);
if (x != y) {
if (sz[x] < sz[y]) swap(x,y);
sz[x] += sz[y];
rt[y] = x;
--comp;
return 1;
} return 0;
}
};
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> N;
FOR(i,1,N){
cin >> X[i] >> Y[i];
}
int e = 0;
FOR(i,1,N){
FOR(j,i+1,N){
el[e++] = edge(SQ(X[i]-X[j])+SQ(Y[i]-Y[j]), i, j);
}
}
sort(el, el+e);
DSU dsu(N);
FOR(i,0,e-1){
dsu.unions(get<1>(el[i]), get<2>(el[i]));
if (dsu.comp == 1) {
cout << fixed << setprecision(7) << sqrt(get<0>(el[i]))/2 << '\n';
return 0;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |