HDU2295-Radar
来源:互联网 发布:网络水军公司bjiko 编辑:程序博客网 时间:2024/06/06 02:16
Radar
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4150 Accepted Submission(s): 1592
Problem Description
N cities of the Java Kingdom need to be covered by radars for being in a state of war. Since the kingdom has M radar stations but only K operators, we can at most operate K radars. All radars have the same circular coverage with a radius of R. Our goal is to minimize R while covering the entire city with no more than K radars.
Input
The input consists of several test cases. The first line of the input consists of an integer T, indicating the number of test cases. The first line of each test case consists of 3 integers: N, M, K, representing the number of cities, the number of radar stations and the number of operators. Each of the following N lines consists of the coordinate of a city.
Each of the last M lines consists of the coordinate of a radar station.
All coordinates are separated by one space.
Technical Specification
1. 1 ≤ T ≤ 20
2. 1 ≤ N, M ≤ 50
3. 1 ≤ K ≤ M
4. 0 ≤ X, Y ≤ 1000
Each of the last M lines consists of the coordinate of a radar station.
All coordinates are separated by one space.
Technical Specification
1. 1 ≤ T ≤ 20
2. 1 ≤ N, M ≤ 50
3. 1 ≤ K ≤ M
4. 0 ≤ X, Y ≤ 1000
Output
For each test case, output the radius on a single line, rounded to six fractional digits.
Sample Input
13 3 23 43 15 41 12 23 3
Sample Output
2.236068
Source
The 4th Baidu Cup final
Recommend
lcy
题意:有n个城市,m个雷达,k个操作员,每个操作员只能操作一个雷达。每个雷达的覆盖范围是一个以雷达坐标为中心的圆,所有雷达的覆盖半径是相同的。现在给出这n个城市,m个雷达的坐标,问雷达覆盖半径最小是多少,让所有城市都可以被雷达覆盖到
解题思路:二分+舞蹈链重复覆盖#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include <cctype> #include <map> #include <cmath> #include <set> #include <stack> #include <queue> #include <vector> #include <bitset> #include <functional> using namespace std;#define LL long long const int INF = 0x3f3f3f3f;const int maxn = 300005;int n, m, K, x[1009], y[1009];struct DLX{int L[maxn], R[maxn], U[maxn], D[maxn];int row[maxn], col[maxn], sum[maxn], ans[maxn];int n, m, num, cnt;int vis[maxn], flag[maxn];void add(int k, int l, int r, int u, int d, int x, int y){L[k] = l; R[k] = r; U[k] = u;D[k] = d; row[k] = x; col[k] = y;}void reset(int n, int m){this->n = n; this->m = m;for (int i = 0; i <= m; i++){add(i, i - 1, i + 1, i, i, 0, i);sum[i] = 0;}L[0] = m, R[m] = 0, cnt = m + 1;}void insert(int x, int y){int temp = cnt - 1;if (row[temp] != x){add(cnt, cnt, cnt, U[y], y, x, y);U[D[cnt]] = cnt; D[U[cnt]] = cnt;}else{add(cnt, temp, R[temp], U[y], y, x, y);R[L[cnt]] = cnt; L[R[cnt]] = cnt;U[D[cnt]] = cnt; D[U[cnt]] = cnt;}sum[y]++, cnt++;}void Remove(int k){for (int i = D[k]; i != k; i = D[i]){L[R[i]] = L[i];R[L[i]] = R[i];}}void Resume(int k){for (int i = U[k]; i != k; i = U[i]) L[R[i]] = R[L[i]] = i;}int A(){int dis = 0;for (int i = R[0]; i != 0; i = R[i]) vis[i] = 0;for (int i = R[0]; i != 0; i = R[i])if (!vis[i]){dis++, vis[i] = 1;for (int j = D[i]; j != i; j = D[j])for (int k = R[j]; k != j; k = R[k])vis[col[k]] = 1;}return dis;}void Dfs(int k){if (!R[0]) num = min(num, k);else if (k + A() < num){int now = R[0];for (int i = R[0]; i != 0; i = R[i])if (sum[now] > sum[i]) now = i;for (int i = D[now]; i != now; i = D[i]){Remove(i);for (int j = R[i]; j != i; j = R[j]) Remove(j);Dfs(k + 1);for (int j = L[i]; j != i; j = L[j]) Resume(j);Resume(i);}}}void mul(){memset(flag, 0, sizeof flag);num = 0x7FFFFFFF;}}dlx;int check(double k){dlx.reset(m, n);for (int i = 1; i <= m; i++)for (int j = 1; j <= n; j++){double temp = (x[n + i] - x[j])*(x[n + i] - x[j]) + (y[n + i] - y[j])*(y[n + i] - y[j]);if (k - sqrt(temp) > 1e-8) dlx.insert(i, j);}dlx.mul();dlx.Dfs(0);if (dlx.num <= K) return 1;return 0;}int main(){int t;scanf("%d", &t);while (t--){scanf("%d%d%d", &n, &m, &K);for (int i = 1; i <= n + m; i++) scanf("%d%d", &x[i], &y[i]);double l = 0, r = 1500;while (r - l > 1e-8){double mid = (l + r) / 2;if (check(mid)) r = mid;else l = mid;}printf("%.6f\n", r);}return 0;}
阅读全文
0 0
- HDU2295-Radar
- DLX hdu2295 Radar
- HDU2295--Radar(Dancing Links)
- hdu2295 Radar 二分+DLX重复覆盖+A*
- HDU2295 Radar(舞蹈链重复覆盖,二分)
- HDU2295 Radar —— Dancing Links 可重复覆盖
- DLX+hdu2295
- radar
- Radar
- Radar
- Radar
- hdu2295(DLX重复覆盖)
- Radar Installation
- Radar Installations
- Radar Installation
- Radar nyist287
- RADAR Brands
- Radar Installation
- skyline里的group
- GET vs POST 区别
- select简述,时区,date,time数据类型
- P1868 饥饿的奶牛
- [2017纪中10-30]Group DP+差分优化
- HDU2295-Radar
- 眼底图像血管增强与分割--(3)基于PCA的增强算法原理及实现
- 图像边缘检测——二阶微分算子(下)Canny算子(Matlab实现)
- 如何清除linux (ubuntu)下的缓存?
- java web连接mysql,汉字乱码显示为“???”
- 清除浮动的几种方法
- 加权最小二乘滤波算法原理及实现
- The specified child already has a parent. You must call removeView() on the
- fread/fwrite实现文件的copy