# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
376258 | 2021-03-11T06:20:36 Z | dantoh000 | Odašiljači (COCI20_odasiljaci) | C++14 | 66 ms | 8664 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef tuple<ll,int,int> iii; int n; int x[1005], y[1005]; vector<iii> edg; int p[1005]; int rk[1005]; int nume = 0; void init(int n){ for (int i = 0; i < n; i++){ p[i] = i; rk[i] = 0; } } int find(int x){ return p[x] == x? x : p[x] = find(p[x]); } void un(int x, int y){ x = find(x) ,y = find(y); if (x == y) return; nume ++; if (rk[x] < rk[y]) swap(x,y); p[y] = x; if (rk[x] == rk[y]) rk[x]++; } int main(){ scanf("%d",&n); for (int i = 0; i < n; i++){ scanf("%d%d",&x[i],&y[i]); } for (int i = 0; i < n; i++){ for (int j = i+1; j < n; j++){ edg.emplace_back((ll)(y[i]-y[j])*(y[i]-y[j]) + (ll)(x[i]-x[j])*(x[i]-x[j]),i,j); } } init(n); sort(edg.begin(),edg.end()); ll ans = 0; for (auto e : edg){ ll d; int x,y; tie(d,x,y) = e; ans = d; un(x,y); //printf("%lld %d %d\n",d,x,y); if (nume == n-1) break; } printf("%.9Lf\n",pow((long double)ans, 0.5)/2); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 492 KB | Output is correct |
6 | Correct | 18 ms | 2676 KB | Output is correct |
7 | Correct | 20 ms | 2528 KB | Output is correct |
8 | Correct | 42 ms | 8664 KB | Output is correct |
9 | Correct | 66 ms | 8664 KB | Output is correct |
10 | Correct | 62 ms | 8664 KB | Output is correct |