Submission #854455

#TimeUsernameProblemLanguageResultExecution timeMemory
854455vjudge1Odašiljači (COCI20_odasiljaci)C++17
0 / 70
1067 ms23044 KiB
#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 timeMemoryGrader output
Fetching results...