# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
474038 | mychecksedad | Odašiljači (COCI20_odasiljaci) | C++17 | 262 ms | 4652 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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.000001f) < 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 |
---|---|---|---|---|
Fetching results... |