# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
496109 | AlperenT | Odašiljači (COCI20_odasiljaci) | C++17 | 452 ms | 336 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
int n;
pair<int, int> arr[N];
long double l, r, m, x, y;
struct DSU{
int par[N], stsize[N], setcnt;
void reset(int n){
for(int i = 1; i <= n; i++) par[i] = i, stsize[i] = 1;
setcnt = n;
}
int setfind(int a){
if(par[a] == a) return a;
else return par[a] = setfind(par[a]);
}
void setunion(int a, int b){
a = setfind(a), b = setfind(b);
if(a != b){
if(stsize[b] > stsize[a]) swap(a, b);
par[b] = par[a];
stsize[a] += stsize[b];
setcnt--;
}
}
};
DSU dsu;
bool check(long double m){
dsu.reset(n);
for(int i = 1; i <= n; i++){
for(int j = i + 1; j <= n; j++){
x = abs(arr[i].first - arr[j].first), y = abs(arr[i].second - arr[j].second);
if(m >= sqrt(x * x + y * y) / 2) dsu.setunion(i, j);
}
}
return dsu.setcnt == 1;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
cin >> n;
for(int i = 1; i <= n; i++) cin >> arr[i].first >> arr[i].second;
l = 0 - 1e-9, r = 1e12;
for(int i = 0; i < 100; i++){
m = l + (r - l) / 2;
if(check(m)) r = m;
else l = m;
}
cout << setprecision(12) << r;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |