Submission #376258

#TimeUsernameProblemLanguageResultExecution timeMemory
376258dantoh000Odašiljači (COCI20_odasiljaci)C++14
70 / 70
66 ms8664 KiB
#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 (stderr)

odasiljaci.cpp: In function 'int main()':
odasiljaci.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
odasiljaci.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   31 |         scanf("%d%d",&x[i],&y[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...