#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define ll long long
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 1000000007
#define lim 200005
using namespace std;
int dad[1005];
int find(int x){
if(dad[x]==x) return x;
return dad[x] = find(dad[x]);
}
void unite(int x, int y){
dad[find(x)] = find(y);
}
void solve(){
int n; cin >> n;
for(int i=1; i<=n; i++){
dad[i]=i;
}
ii arr[n+1];
for(int i=1; i<=n; i++) cin >> arr[i].st >> arr[i].nd;
vector<tuple<double, int, int>> wow;
for(int i=1; i<=n; i++){
for(int j=i+1; j<=n; j++){
int sq1, sq2;
sq1 = (arr[i].st-arr[j].st)*(arr[i].st-arr[j].st);
sq2 = (arr[i].nd-arr[j].nd)*(arr[i].nd-arr[j].nd);
wow.pb({sqrt(((double)sq1 + (double)sq2))/(double)2, i, j});
//cerr << sqrt((double)sq1 + (double)sq2) / ((double)2) << endl;
}
}
sort(all(wow));
double ans;
for(auto t:wow){
//cerr << get<0>(t) << endl;
int a=get<1>(t),b=get<2>(t);
if(find(a)==find(b)) continue;
unite(a,b);
ans = get<0>(t);
}
cout << setprecision(15) << ans << endl;
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
ll t=1;
//cin >> t;
while(t--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
15 ms |
3536 KB |
Output is correct |
7 |
Correct |
15 ms |
3536 KB |
Output is correct |
8 |
Correct |
35 ms |
13256 KB |
Output is correct |
9 |
Correct |
59 ms |
14276 KB |
Output is correct |
10 |
Correct |
54 ms |
13252 KB |
Output is correct |