The processing of vertices discretization is used, and then the processing can be done in two minutes...
Radar
time limit: 2000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/others) total submission (s): 1928 accepted submission (s ): 796
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 input1
3 3 2
3 4
3 1
5 4
1 1
2 2
3 3
Sample output2.236068
Sourcethe 4th Baidu Cup Final
Recommendlcy
# Include <stdio. h> # Include <Algorithm> # Include <String . H> # Include <Math. h> # Include <Iostream> Using Namespace STD; # Define N 10000 # Define INF 0x3fffffff Struct Node { Double X, Y;} GN [ 55 ], GM [ 55 ]; Int N, m, K; Int U [N], d [N], R [N], L [N], num [N], H [N], Col [N], line [N]; Int Head, ID, mi; Int Nn, mm; Double G [N]; Double Cal (node T, node T1 ){ Return SQRT (T. x-t1.x) * (T. x-t1.x) + (T. y-t1.y) * (T. Y- T1.y ));} Void Prepare (){ For ( Int I = 0 ; I <= mm; I ++ ) {Num [I] = 0 ; U [I] = I; d [I] = I; R [I] = I + 1 ; L [I + 1 ] = I;} R [mm] = 0 ; L [ 0 ] = Mm; memset (H, - 1 , Sizeof (H ));} Void Link ( Int TN, Int TM) {ID ++ ; Num [line [ID] = Tm] ++ ; Col [ID] = TN; U [d [Tm] =ID; d [ID] = D [Tm]; U [ID] = TM; d [Tm] = ID; If (H [tn] < 0 ) H [tn] = R [ID] = L [ID] = ID; Else {L [R [H [tn] = ID; R [ID] = R [H [tn]; L [ID] = H [tn]; R [H [tn] = ID ;}} Int H (){ Int Mark [ 66 ]; Memset (mark, 0 , Sizeof (Mark )); Int Sum = 0 ; For ( Int I = R [head]; I! = Head; I = R [I]) { If (MARK [I] =0 ) {Sum ++ ; Mark [I] = 1 ; For ( Int J = d [I]; J! = I; j = D [J]) For ( Int K = R [J]; k! = J; k = R [k]) MARK [line [k] = 1 ;}} Return SUM ;} Void Remove ( Int S ){ For ( Int I = d [s]; I! = S; I = D [I]) {R [L [I] = R [I]; L [R [I] = L [I] ;}} Void Resume ( Int S ){ For (Int I = U [s]; I! = S; I = U [I]) R [L [I] = L [R [I] = I ;} Void DFS ( Int S ){ If (S + H ()> = mi) Return ; If (R [head] = Head) {mi = S; Return ;} Int TMI = INF, Tu; For ( Int I = R [head]; I! = Head; I = R [I]) { If (Num [I] < TMI) {TMI = Num [I]; TU = I ;}} For ( Int I = d [Tu]; I! = Tu; I = D [I]) {remove (I ); For ( Int J = R [I]; J! = I; j = R [J]) Remove (j); DFS (S + 1 ); For ( Int J = L [I]; J! = I; j = L [J]) Resume (j); resume (I );}} Int DLX ( Double Key) {head = 0 ; Mm = N; NN =1 ; Prepare (); Id = Mm; For ( Int I = 1 ; I <= m; I ++ ){ Int Flag = 0 ; For ( Int J = 1 ; J <= N; j ++ ){ If (CAL (GN [J], GM [I]) <= Key) {flag = 1 ; Link (I, j );}} If (Flag = 1 ) Nn ++ ;} Mi = INF; DFS ( 0 ); If (MI <= K) Return 1 ; Else Return 0 ;} Int Main (){ Int T; scanf ( " % D " ,& T ); While (T -- ) {Scanf ( " % D " , & N, & M ,& K ); For ( Int I = 1 ; I <= N; I ++ ) {Scanf ( " % Lf " , & GN [I]. X ,& GN [I]. Y );} For ( Int I = 1 ; I <= m; I ++) {Scanf ( " % Lf " , & GM [I]. X ,& GM [I]. Y );} Int CNT = 0 ; For ( Int I = 1 ; I <= N; I ++ ) For ( Int J =1 ; J <= m; j ++ ) {G [CNT ++] = Cal (GN [I], GM [J]);} Sort (G, G + CNT ); Int B = 0 , D = CNT- 1 ; While (B < D ){ Int Mid = (B + d )/ 2 ; // Because D is selected, D must not be equal to mid. If (DLX (G [Mid]) = 1 ) {D = Mid; // The key thing to grasp is to find the largest and the smallest, so that which of the = mid is not equal to the mid as much as possible. } Else {B = Mid + 1 ;}} Double Ans; ans = (G [B] *10000000 + 0.5 )/ 10000000 ; Printf ( " %. 6lf \ n " , G [B]);} Return 0 ;}