#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define forp(i,l,r) for (int i = (l); i < (r); i ++)
#define forp1(j,l,r) for (int j = (l); j < (r); j ++)
#define form(i,l,r) for (int i = (r); i >= (l); i --)
#define form1(j,l,r) for (int j = (r); j >= (l); j --)
#define minset(x) (*((x).begin()))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define setp cout << fixed << setprecision(15)
#define all(x) (x).begin(), (x).end()
#define IOS ios::sync_with_stdio(false)
typedef long long ll;
using namespace std;
const int MAX_N = 1e3 + 13, MOD = 1e9 + 7, inf = 1e9 + 19;
ll INF = 1e18 + 118;
vector<int> adj[MAX_N];
pii cor[MAX_N];
bool vis[MAX_N];
void dfs(int root)
{
vis[root] = 1;
for (int u: adj[root]) {
if (!vis[u]) {
dfs(u);
}
}
}
int main()
{
IOS;
cin.tie(0);
int n;
cin >> n;
forp(i, 1, n + 1) {
cin >> cor[i].ff >> cor[i].ss;
}
double l = 0, r = inf, mid, difx, dify;
forp(i, 0, 51) {
bool cmp = 0;
mid = (l + r) / 2;
forp(i, 1, n + 1) {
forp1(j, i + 1, n + 1) {
difx = abs(cor[i].ff - cor[j].ff);
dify = abs(cor[i].ss - cor[j].ss);
if (sqrt((difx * difx) + (dify * dify)) <= mid) {
adj[i].pb(j);
adj[j].pb(i);
}
}
}
forp(i, 1, n + 1) {
if (!vis[i]) {
if (!cmp) {
cmp = 1;
dfs(i);
}
else {
cmp = 0;
break;
}
}
}
forp(i, 1, n + 1) {
adj[i].clear();
}
if (!cmp)
l = mid;
else
r = mid;
fill(vis, vis + n + 2, 0);
}
setp << r / 2 << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
6 |
Correct |
53 ms |
1364 KB |
Output is correct |
7 |
Correct |
50 ms |
1372 KB |
Output is correct |
8 |
Correct |
106 ms |
3412 KB |
Output is correct |
9 |
Correct |
147 ms |
4460 KB |
Output is correct |
10 |
Correct |
116 ms |
3312 KB |
Output is correct |