HDU 2295 Radar (repeated DLX coverage)
Problem DescriptionN 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.
InputThe 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
OutputFor 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
SourceThe 4th Baidu Cup final question: In n cities and m radar stations, at most k radar stations are used. Ask you the minimum coverage radius of each radar station. Repeated DLX coverage: We can consider using m radar stations as N and n cities as M to form a repeated DLX coverage model. Then how can we determine the bool value of N * M? We consider the radius r of binary. For the radius r of every binary, we can find the bool matrix 0 and 1 based on the distance, then there is the repeated coverage model of DLX. It is worth noting that a maximum of k radar stations are also important for pruning.
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
Using namespace std; # define REPF (I, a, B) for (int I = a; I <= B; ++ I) # define REP (I, n) for (int I = 0; I <n; ++ I) # define CLEAR (a, x) memset (a, x, sizeof a) typedef long LL; typedef pair
Pil; const int maxn = 55; const int maxnnode = maxn * maxn; const int mod = 1000000007; const double eps = 1e-8; int K; struct DLX {int n, m, size; int U [maxnnode], D [maxnnode], L [maxnnode], R [maxnnode], Row [maxnnode], Col [maxnnode]; int H [maxn], S [maxn]; // H [I] location, S [I] Count int ansd, ans [maxn]; void init (int a, int B) {n =; m = B; REPF (I, 0, m) {S [I] = 0; U [I] = D [I] = I; L [I] = I-1; R [I] = I + 1;} R [m] = 0; L [0] = m; size = m; REPF (I, 1, n) H [I] =-1;} void link (int r, int c) {++ S [Col [++ size] = c]; Row [size] = r; D [size] = D [c]; U [D [c] = size; U [size] = c; D [c] = size; if (H [r] <0) H [r] = L [size] = R [size] = size; else {R [size] = R [H [r]; L [R [H [r] = size; L [size] = H [r]; R [H [r] = size ;}} void remove (int c) {for (int I = D [c]; I! = C; I = D [I]) L [R [I] = L [I], R [L [I] = R [I];} void resume (int c) {for (int I = U [c]; I! = C; I = U [I]) L [R [I] = R [L [I] = I;} bool v [maxnnode]; int f () {int ret = 0; for (int c = R [0]; c! = 0; c = R [c]) v [c] = true; for (int c = R [0]; c! = 0; c = R [c]) if (v [c]) {ret ++; v [c] = false; for (int I = D [c]; i! = C; I = D [I]) for (int j = R [I]; j! = I; j = R [j]) v [Col [j] = false;} return ret;} bool Dance (int d) {if (d + f ()> k) return false; if (R [0] = 0) return d <= K; int c = R [0]; for (int I = R [0]; i! = 0; I = R [I]) if (S [I] <S [c]) c = I; for (int I = D [c]; I! = C; I = D [I]) {remove (I); for (int j = R [I]; j! = I; j = R [j]) remove (j); if (Dance (d + 1) return true; for (int j = L [I]; j! = I; j = L [j]) resume (j); resume (I) ;}return false ;}; struct point {int x, y ;} X [maxn], Y [maxn]; dlx l; int T, N, M; double dis (point a, point B) {return sqrt (double) (. x-b.x) * (. x-b.x) + (double) (. y-b.y) * (. y-b.y);} void solve () {double l = 0, r = 1e8; while (r-l> = eps) {double mid = (l + r)/2; l. init (M, N); for (int I = 1; I <= M; I ++) {for (int j = 1; j <= N; j ++) {if (dis (X [I], Y [j])
Problem DescriptionN 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.
InputThe 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
OutputFor 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
SourceThe 4th Baidu Cup final