Submission #854455

# Submission time Handle Problem Language Result Execution time Memory
854455 2023-09-27T16:52:49 Z vjudge1 Odašiljači (COCI20_odasiljaci) C++17
0 / 70
1000 ms 23044 KB
#include <bits/stdc++.h>
using namespace std;
#define sp << " " << 
#define int long long
#define vi vector<int>
#define pb push_back
#define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++)
#define pii pair<int,int>
const int N = 1e3+1;
vi dad(N);

int find(int x) {
	if (x == dad[x]) return x;
	return dad[x] = find(dad[x]);
}

void unite(int x,int y) {
	dad[find(x)] = find(y);
}

void solve() {
	int n;
	cin >> n;
	vector<pair<pii,double>> edg;
	vi x(n+1),y(n+1);
	for (int i=1;i<=n;i++) cin >> x[i] >> y[i];
	for (int i=1;i<=n;i++) {
		for (int j=i+1;j<=n;j++) {
			int dx = x[i]-x[j];
			int dy = y[i]-y[j];
			edg.pb({{i,j},sqrtl(dx*dx+dy*dy)});
			cout << i sp j sp sqrtl(dx*dx+dy*dy) << endl;
		}
	}
	double l = 0;
	double r = 1e9;
	double eps = 1e-8;
	cout << setprecision(12);
	while (l<=r) {
		double v = (l+r)/2;
		for (int i=1;i<=n;i++) dad[i] = i;;
		for (auto it : edg) {
			if (it.second <= 2*v) {
				unite(it.first.first,it.first.second);
				cout << it.first.first sp it.first.second << endl;
			}
		}
		int c = 1;
		for (int i=1;i<=n;i++) c&=(find(i) == find(1)); 
		if (c) r = v-eps;
		else l = v+eps;
	}
	cout << l << endl;
}     
                                
signed main() { 
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t; 
    while (t --> 0) solve();
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Incorrect 2 ms 348 KB Output isn't correct
3 Incorrect 47 ms 680 KB Output isn't correct
4 Incorrect 70 ms 852 KB Output isn't correct
5 Incorrect 40 ms 860 KB Output isn't correct
6 Execution timed out 1064 ms 10988 KB Time limit exceeded
7 Execution timed out 1067 ms 11156 KB Time limit exceeded
8 Execution timed out 1034 ms 17288 KB Time limit exceeded
9 Execution timed out 1043 ms 20544 KB Time limit exceeded
10 Execution timed out 1063 ms 23044 KB Time limit exceeded