The main topic: play a bomb game, there is a chance to put bombs, every time you put bombs, you have two places to choose, ask how to put bombs, can make the explosion of the bomb radius of the smallest maximum (bomb explosion radius can be controlled, but the explosion formed by the circle cannot have overlapping parts)
The best way to solve problems: minimum value, two points
The two-part radius, if there is not satisfied with the point, set up a limit edge, and then determine whether the dyeing can be completed
#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <vector>using namespace STD;#define ESP 1e-5#define NstructNode {intx, y;} node[n][2];BOOLMark[n]; vector<int>G[n];intTop, N, M;intS[n];voidInit () { for(inti =0; I < n; i++) {scanf("%d%d%d%d", &node[i][0].x, &node[i][0].Y, &node[i][1].x, &node[i][1].Y); }}DoubleDistanceintIintAintJintb) {return sqrt(1.0* (node[i][a].x-node[j][b].x) * (node[i][a].x-node[j][b].x) +1.0* (NODE[I][A].Y-NODE[J][B].Y) * (NODE[I][A].Y-NODE[J][B].Y));}voidAddedge (intIintAintJintb) {intx = i *2+ A;inty = J *2+ b; g[x ^1].push_back (y); G[y ^1].push_back (x);}BOOLDfsintu) {if(mark[u ^1])return false;if(Mark[u])return true; Mark[u] =true; S[++top] = u; for(inti =0; I < g[u].size (); i++)if(!dfs (G[u][i]))return false;return true;}BOOLJudgeDoubleMID) { for(inti =0; I <2N i++) g[i].clear (); for(inti =0; I < n; i++) { for(intj = i +1; J < N; J + +) { for(intA =0; A <2; a++) for(intb =0; b <2; b++) {//printf ("Dis is%lf\n", distance (I, A, J, b)); if(2* Mid-distance (I, A, J, b) > ESP) {addedge (I, A, J, b); } } } }memset(Mark,0,sizeof(Mark)); for(inti =0; I <2N i + =2) {if(!mark[i] &&!mark[i ^1]) {top =0;if(!dfs (i)) { while(top) mark[s[top--]] =false;if(!dfs (i ^1))return false; } } }return true;}voidSolve () {DoubleL =0, r =1e5; for(inti =0; I < -; i++) {DoubleMid = (L + r)/2;//printf ("L am%LF R is%lf mid is%lf\n", L, R, mid); if(Judge (mid)) L = mid;ElseR = Mid; }printf("%.2lf\n", l);}intMain () { while(scanf("%d", &n)! = EOF) {init (); Solve (); }return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
HDU-3622 Bomb Game (two minutes +2-sat)