제출 #376236

#제출 시각아이디문제언어결과실행 시간메모리
376236lycOdašiljači (COCI20_odasiljaci)C++14
70 / 70
57 ms8172 KiB
#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 timeMemoryGrader output
Fetching results...