Submission #445479

# Submission time Handle Problem Language Result Execution time Memory
445479 2021-07-18T08:38:26 Z grt Odašiljači (COCI20_odasiljaci) C++17
70 / 70
64 ms 8640 KB
#include <bits/stdc++.h>
#define ST first
#define ND second
#define PB push_back

using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;

struct P {
	int x, y;
};

const int nax = 1000 + 10;
int n;
P p[nax];
vector<tuple<ll,int,int>>d;
int par[nax], siz[nax];

int Fund(int x) {
	if(par[x] != x) par[x] = Fund(par[x]);
	return par[x];
}

ll ans;

void Onion(int a, int b, ll c) {
	a = Fund(a); b = Fund(b);
	if(a == b) return;
	ans = c;
	if(siz[a] < siz[b]) swap(a, b);
	siz[a] += siz[b];
	par[b] = a;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; ++i) {
		cin >> p[i].x >> p[i].y;
		par[i] = i;
		siz[i] =1;
	}
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			d.PB({(ll)(p[i].x - p[j].x) * (p[i].x - p[j].x) + (ll)(p[i].y - p[j].y) * (p[i].y - p[j].y), i, j});
		}
	}
	sort(d.begin(), d.end());
	for(auto [c, u, v] : d) {
		Onion(u,v,c);
	}
	long double res = sqrtl(ans) / 2.0;
	cout << setprecision(10);
	cout << fixed;
	cout << res;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 18 ms 2504 KB Output is correct
7 Correct 17 ms 2504 KB Output is correct
8 Correct 42 ms 8628 KB Output is correct
9 Correct 64 ms 8632 KB Output is correct
10 Correct 62 ms 8640 KB Output is correct