Bomb gametime limit: 3000 msmemory limit: 32768 kbthis problem will be judged on HDU. Original ID: 3622
64-bit integer Io format: % i64d Java class name: Main Robbie is playing an interesting computer game. the game field is an unbounded 2-dimen1_region. there are n rounds in the game. at each round, the computer will give Robbie two places, and Robbie shoshould choose one of them to put a bomb. the explosion area of the bomb is a circle whose center is just the chosen place. robbie can control the power of the bomb, that is, he can control the radius of each circle. A strange requirement is that there shoshould be no common area for any two circles. the final score is the minimum radius of all the N circles.
Robbie has cracked the game, and he has known all the candidate places of each round before the game starts. Now he wants to know the maximum score he can get with the optimal strategy.
Inputthe first line of each test case is an integer N (2 <= n <= 100), indicating the number of rounds. then n lines follow. the I-th line contains four integers x1i, y1i, x2i, y2i, indicating that the coordinates of the two candidate places of the I-th round are (x1i, y1i) and (x2i, y2i ). all the coordinates are in the range [-10000,100 00].
Outputoutput one float number for each test case, indicating the best possible score. The result shocould be rounded to two decimal places.
Sample Input
21 1 1 -1-1 -1 -1 121 1 -1 -11 -1 -1 1
Sample output
1.411.00
Source2010 Asia Regional Tianjin site -- online contest solution: select one of the two bombs in each row, but the explosion ranges of the two adjacent bombs cannot overlap and can be tangent. The explosion ranges of all bombs are the same, find the maximum explosion range. Typical 2-sat. If you want to maximize the performance, you can just divide it into two points. Pay attention to the accuracy. At least 1e-5; otherwise, WA will be used.
1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 # include <cmath> 5 # include <algorithm> 6 # include <climits> 7 # include <vector> 8 # include <queue> 9 # include <cstdlib> 10 # include <string> 11 # include <set> 12 # include <stack> 13 # define ll long 14 # define PII pair <int, int> 15 # define INF 0x3f3f3f 16 using namespace STD; 17 const int maxn = 250; 18 const double exps = 1e-5; 19 struct arc {20 int to, next; 21 arc (INT x = 0, int y =-1) {22 to = x; 23 next = y; 24} 25 }; 26 struct node {27 int X, Y; 28}; 29 node P [maxn]; 30 arc E [maxn * 10]; 31 int head [maxn], TOT, dfn [maxn], low [maxn], belong [maxn], SCC, CNT, N; 32 bool instack [maxn]; 33 stack <int> STK; 34 void add (int u, int v) {35 E [tot] = arc (v, head [u]); 36 head [u] = tot ++; 37} 38 double DIS (const node & A, const node & B) {39 double TMP = (. x-B. x) * (. x-B. x) + (. y-B. y) * (. y-B. y); 40 return SQRT (TMP); 41} 42 void Tarjan (int u) {43 dfn [u] = low [u] = ++ CNT; 44 STK. push (U); 45 instack [u] = true; 46 for (INT I = head [u]; ~ I; I = E [I]. Next) {47 If (! Dfn [E [I]. to]) {48 Tarjan (E [I]. to); 49 low [u] = min (low [u], low [E [I]. to]); 50} else if (instack [E [I]. to]) low [u] = min (low [u], dfn [E [I]. to]); 51} 52 If (low [u] = dfn [u]) {53 SCC ++; 54 int V; 55 do {56 v = STK. top (); 57 STK. pop (); 58 instack [v] = false; 59 belong [v] = SCC; 60} while (V! = U); 61} 62} 63 bool solve () {64 While (! STK. empty () STK. pop (); 65 for (INT I = 0; I <maxn; I ++) {66 belong [I] = dfn [I] = low [I] = 0; 67 instack [I] = false; 68} 69 SCC = CNT = 0; 70 for (INT I = 0; I <n <1; I ++) 71 If (! Dfn [I]) Tarjan (I); 72 for (INT I = 0; I <n; I ++) 73 If (belong [I <1] = belong [I <1 | 1]) return false; 74 return true; 75} 76 int main () {77 int X, Y; 78 double low, high, mid; 79 while (~ Scanf ("% d", & N) {80 for (INT I = 0; I <n; I ++) 81 scanf ("% d", & P [I <1]. x, & P [I <1]. y, & P [I <1 | 1]. x, & P [I <1 | 1]. y); 82 low = 0; 83 high = 2000.0; 84 while (FABS (high-low)> exps) {85 mid = (high + low)/2.0; 86 memset (Head,-1, sizeof (head); 87 for (INT I = tot = 0; I <(n-1) <1; I ++) {88 for (Int J = I & 1? I + 1: I + 2; j <n <1; j ++) {89 If (DIS (P [I], p [J]) <2.0 * mid) {// I and j cannot coexist 90 add (I, j ^ 1); 91 add (J, I ^ 1 ); 92} 93} 94} 95 If (solve () Low = mid; 96 else high = mid; 97} 98 printf ("%. 2f \ n ", high); 99} 100 return 0; 101}
View code
HDU 3622 bomb game