Submission #474037

# Submission time Handle Problem Language Result Execution time Memory
474037 2021-09-16T16:57:52 Z mychecksedad Odašiljači (COCI20_odasiljaci) C++17
56 / 70
1000 ms 4656 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
const int N = 1010, F = 1e9;


int n;
struct P{
	ll x, y;
	double dist(P a){
		return sqrt((x - a.x) * (x - a.x) + (y - a.y) * (y - a.y));
	}
};
bool check(vector<vector<int>> &g){
	queue<int> q;
	vector<bool> v(1001, 0);
	q.push(0);
	v[0] = 1;
	while(!q.empty()){
		int x = q.front();
		q.pop();
		for(int u: g[x]){
			if(!v[u]){
				v[u] = 1;
				q.push(u);
			}
		}
	}
	bool ok = 1;
	for(int i=0;i<n;i++) ok&=v[i];
	return ok;
}
int main(){
	cin.tie(0); ios::sync_with_stdio(0);
	P arr[N];
	cin >> n;
	for(int i = 0; i < n; i++) cin >> arr[i].x >> arr[i].y;
	double l = 0, r = 2*F, ans = 2*F;
	while(l + (0.000000001f) < r){
		double mid = (l+r)/2.0;
		vector<vector<int>> g(N);
		for(int i = 0; i < n; i++){
			for(int j = i+1; j < n; j++){
				double d = arr[i].dist(arr[j]);
				if(d <= mid){
					g[i].pb(j);
					g[j].pb(i);
				}
			}
		}
		if(check(g)){
			ans = min(ans, mid);
			r = mid;
		}else l = mid;
	}


	cout << fixed <<  setprecision(15);
	cout << l/2.0;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 5 ms 332 KB Output is correct
5 Execution timed out 1068 ms 332 KB Time limit exceeded
6 Correct 108 ms 1424 KB Output is correct
7 Correct 121 ms 1396 KB Output is correct
8 Correct 232 ms 3456 KB Output is correct
9 Correct 299 ms 4656 KB Output is correct
10 Execution timed out 1093 ms 4648 KB Time limit exceeded