Submission #332186

#TimeUsernameProblemLanguageResultExecution timeMemory
332186DanerZeinOdašiljači (COCI20_odasiljaci)C++14
14 / 70
1093 ms492 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> ii; const ll MAX=1e9; int ns; double raiz(ll x){ double l=0,r=MAX; for(int i=0;i<=40;i++){ double mid=(l+r)/2; if(mid*mid>=x)r=mid; else l=mid; } return r; } int pa[1010]; void init(int n){ for(int i=0;i<n;i++) pa[i]=i; ns=n; } int findset(int i){ if(pa[i]==i) return pa[i]; return pa[i]=findset(pa[i]); } bool issameset(int i,int j){ return findset(i)==findset(j); } void unionset(int i,int j){ if(!issameset(i,j)){ int x=findset(i),y=findset(j); ns--; pa[x]=y;; } } vector<ii> x; bool check(double r,int n){ init(n); //cout<<r<<endl; for(int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){ if(!issameset(i,j)){ double a=abs(x[i].first-x[j].first); double b=abs(x[i].second-x[j].second); double dist=raiz((a*a)+(b*b)); dist/=2; // cout<<i<<" "<<j<<" "<<dist<<" "<<r<<" "<<ns<<endl; if(dist<=r) unionset(i,j); } } } if(ns==1) return true; return false; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin>>n; for(int i=0;i<n;i++){ int a,b; cin>>a>>b; x.push_back(ii(a,b)); } ld l=0,r=MAX; for(int i=0;i<=60;i++){ ld mid=(l+r)/2; if(check(mid,n)){ r=mid; } else l=mid; //break; } printf("%.7llf\n",r); }

Compilation message (stderr)

odasiljaci.cpp: In function 'int main()':
odasiljaci.cpp:75:16: warning: use of 'll' length modifier with 'f' type character has either no effect or undefined behavior [-Wformat=]
   75 |   printf("%.7llf\n",r);
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...