0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-16 20:05:26 +00:00

P2498 [SDOI2012]拯救小云公主

https://www.luogu.com.cn/record/85636345
This commit is contained in:
Baoshuo Ren 2022-09-01 16:39:34 +08:00
parent fd91640146
commit a0a0b5d506
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

74
Luogu/P2498/P2498.cpp Normal file
View File

@ -0,0 +1,74 @@
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <queue>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 3005;
const double eps = 1e-4;
int n, row, line;
std::pair<int, int> a[N];
bool vis[N];
bool check(double x) {
std::fill_n(vis, N, false);
std::queue<int> q;
for (int i = 1; i <= n; i++) {
if (a[i].first - 1 < x || line - a[i].second < x) {
vis[i] = true;
q.push(i);
}
}
while (!q.empty()) {
auto u = q.front();
q.pop();
if (row - a[u].first < x || a[u].second - 1 < x) {
return false;
}
for (int i = 1; i <= n; i++) {
if (!vis[i] && std::sqrt(std::pow(a[u].first - a[i].first, 2) + std::pow(a[u].second - a[i].second, 2)) < x * 2) {
vis[i] = true;
q.push(i);
}
}
}
return true;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> row >> line;
for (int i = 1; i <= n; i++) {
cin >> a[i].first >> a[i].second;
}
double l = 0, r = std::min(row, line);
while (r - l > eps) {
double mid = (l + r) / 2;
if (check(mid)) {
l = mid;
} else {
r = mid;
}
}
cout << std::fixed << std::setprecision(2) << l << endl;
return 0;
}