#include <bits/stdc++.h>
#define pdi pair <double, int>
using namespace std;
struct Coord{
int x, y;
};
vector <Coord> a;
vector <double> d;
vector <vector <double>> w;
int n;
double ans = 0;
double Distance(Coord i, Coord j){
return sqrt(pow(i.x - j.x, 2) + pow(i.y - j.y, 2));
}
double Dijkstra(){
priority_queue <pdi, vector <pdi>, greater <pdi>> pq; pq.push({d[0], 0});
while (!pq.empty()){
int p = pq.top().second; pq.pop();
ans = max(ans, d[p]);
d[p] = -1;
for (int k = 0; k < n; k++)
if (d[k] > w[k][p]){
d[k] = w[k][p];
pq.push({d[k], k});
}
}
return ans / 2;
}
void Solve(){
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
w[i][j] = Distance(a[i], a[j]);
cout << fixed << setprecision(7) << Dijkstra();
}
int main() {
cin >> n;
a.resize(n);
d.resize(n, INFINITY); d[0] = 0;
w.resize(n, vector <double> (n));
for (auto &i : a)
cin >> i.x >> i.y;
Solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
6 |
Correct |
37 ms |
2644 KB |
Output is correct |
7 |
Correct |
25 ms |
2896 KB |
Output is correct |
8 |
Correct |
82 ms |
5328 KB |
Output is correct |
9 |
Correct |
351 ms |
8784 KB |
Output is correct |
10 |
Correct |
429 ms |
9292 KB |
Output is correct |