답안 #473895

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
473895 2021-09-16T11:33:55 Z BidoTeima Odašiljači (COCI20_odasiljaci) C++17
70 / 70
209 ms 4684 KB
/// isA AC
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void ACPLS()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
#define tc         \
    int tttttt,subtask;    \
    cin >> tttttt /*>> subtask*/; \
    while (tttttt--)
#define sumrange(l, r, arr) (l == 0 ? arr[r] : arr[r] - arr[l - 1])
#define all(v) v.begin(), v.end()
bool touch( double x1,  double y1,  double x2,
            double y2,  double r1,  double r2)
{
     double distSq = (x1 - x2) * (x1 - x2) +
                 (y1 - y2) * (y1 - y2);
     double radSumSq = (r1 + r2) * (r1 + r2);
    if (radSumSq>=distSq)
        return 1;
    return 0;
}
vector<int>adj[(int)1e3+5];
vector<bool>vis(1e3+3,0);
bool dfs(int curnode){
    if(vis[curnode])
        return 0;
    vis[curnode]=1;
    bool ret=0;
    for(int child:adj[curnode]){
        ret|=dfs(child);
    }
    return ret;
}
int n;
pair< double, double> a[(int)1e3+5];
bool check( double r){
    for(int i = 0; i <= n; i++)
        adj[i]=vector<int>();
    vis=vector<bool>(n+5,0);
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if(touch(a[i].first,a[i].second,
                a[j].first,a[j].second,r,r)){
                adj[i].push_back(j);
                adj[j].push_back(i);
            }
        }
    }
    dfs(0);
    bool ok=1;
    for(int i = 0; i < n; i++){
        ok&=vis[i];
    }
    return ok;
}
int main()
{
    ACPLS();
    cin>>n;
    for(int i = 0; i < n; i++)
        cin>>a[i].first>>a[i].second;
    double lo=0,hi=1e9,ans=hi;
    int it=0;
    while(it<50){
        double mid = (lo+hi)*0.5;
        if(check(mid)){
            ans=mid;
            hi=mid;
        }
        else lo=mid;
        ++it;
    }
    cout<<fixed<<setprecision(6);
    cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 416 KB Output is correct
6 Correct 87 ms 1448 KB Output is correct
7 Correct 86 ms 1464 KB Output is correct
8 Correct 197 ms 3464 KB Output is correct
9 Correct 209 ms 4644 KB Output is correct
10 Correct 129 ms 4684 KB Output is correct