Submission #337378

# Submission time Handle Problem Language Result Execution time Memory
337378 2020-12-20T10:41:03 Z Jarif_Rahman Odašiljači (COCI20_odasiljaci) C++17
70 / 70
290 ms 4856 KB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
typedef double ld;
vector<vector<int>> g;
vector<bool> bl;
void dfs(int nd){
    if(bl[nd]) return;
    bl[nd] = 1;
    for(int x: g[nd]) dfs(x);
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    vector<pair<ld, ld>> v(n);
    for(auto &p: v) cin >> p.f >> p.sc;
    ld a = 0, b = 1e9;
    while(1){
        if(b-a <= (1e-6)) break;
        ld c = (a+b)/2.0;
        bool bll = 1;
        g.clear();
        g.resize(n);
        bl.clear();
        bl.resize(n, 0);
        for(int i = 0; i < n; i++) for(int j = i+1; j < n; j++){
            ld dis = (v[i].f-v[j].f)*(v[i].f-v[j].f) + (v[i].sc-v[j].sc)*(v[i].sc-v[j].sc);
            dis = sqrt(dis);
            dis/=2.0;
            if(dis <= c){
                g[i].pb(j);
                g[j].pb(i);
            }
        }
        dfs(0);
        for(int i = 0; i < n; i++) bll&=bl[i];
        if(bll) b = c;
        else a = c;
    }
    cout << setprecision(100) << a << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 2 ms 364 KB Output is correct
4 Correct 4 ms 364 KB Output is correct
5 Correct 4 ms 364 KB Output is correct
6 Correct 109 ms 1484 KB Output is correct
7 Correct 110 ms 1496 KB Output is correct
8 Correct 247 ms 3584 KB Output is correct
9 Correct 290 ms 4856 KB Output is correct
10 Correct 193 ms 4844 KB Output is correct