HDU-3622 Bomb Game (two minutes +2-sat)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.