Test instructions: give n to the location of the bomb can be placed (each position is a two-dimensional plane point), each time the bomb is placed only select one of the two points, each bomb explosion radius is the same, the radius of the control explosion so that all the explosion range does not intersect (can be tangent), to solve the maximum radius.
Idea: Two-point answer, then build a diagram, use 2-sat to determine whether the plan is feasible.
#include <iostream> #include <map> #include <string> #include <cstring> #include <cstdio> #include <cstdlib> #include <cmath> #include <queue> #include <vector> #include <algorithm >using namespace std;double r;const double eps=1e-5;const int maxn = 110;struct twosat{int n,c; Vector<int> g[maxn<<1]; BOOL mark[maxn<<1]; int s[maxn<<1]; bool Dfs (int x) {int i; if (mark[x^1]) return 0; if (Mark[x]) return 1; MARK[X] = 1; S[c++] = x; for (i = 0; i < g[x].size (); i++) if (!dfs (G[x][i])) return 0; return 1; } void init (int n) {int i,t=n<<1; This->n = n; for (i = 0; i < T; i++) g[i].clear (); memset (mark, 0, sizeof (Mark)); } void Add_clause (int x, int xval, int y, int yval) {x = x * 2 + xval; y = y * 2 + yval; G[x^1].push_back (y); G[y^1].push_back (x); } bool Solve () {int i,t=n<<1; for (i = 0; i < T; i + = 2) if (!mark[i] &&!mark[i + 1]) {c = 0; if (!dfs (i)) {while (C > 0) mark[s[--c]] = 0; if (!dfs (i + 1)) return 0; }} return 1; }}woker; struct point{double x,y;double dis (point a) {return sqrt (POW (x-a.x,2) +pow (y-a.y,2));}} In[110][2];bool isOK (Point A,point b) {return! A.dis (b) >2*r);} void Create (int n) {int i,j,x,y;woker.init (n); for (i=0;i<n;i++) for (j=i+1;j<n;j++) for (x=0;x<2;x++) for (y=0;y <2;y++) if (isOK (In[i][x],in[j][y])) Woker.add_clause (i,x,j,y);} int main () {int i,j,n;double low,high;while (cin>>n) {for (i=0;i<n;i++) for (j=0;j<2;j++) cin>>in[i][j ].x>>in[i][j].y;low=0;high=1e5;while (high-low>eps) {r= (High+low)/2;create (n); if (Woker.solve ()) low=r; Elsehigh=r;} printf ("%.2f\n", Low);} return 0;}
Bomb Game
Time limit:10000/3000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 4034 Accepted Submission (s): 1420
Problem Descriptionrobbie is playing an interesting computer game. The game field is a unbounded 2-dimensional region. There is N rounds in the game. At each round, the computer would give Robbie the places, and Robbie should choose one of the them to put a bomb. The explosion area of the bomb is a circle whose center are just the chosen place. Robbie can control the power of the bomb, that's, he can control the radius of each circle. A Strange requirement is this there should be no common area for any of the circles. The final score is the minimum radius of all the N circles.
Robbie has cracked the game, and he have 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 all test case was an integer n (2 <= n <=), 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 and candidate of th E i-th round is (x1i, y1i) and (X2i, y2i). All the coordinates is in the range [-10000, 10000].
Outputoutput one float number for each test case, indicating the best possible score. The result should is rounded to both 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
HDU 3622 Bomb Game