Description
\ (n\) A bomb, each bomb has two placement points, you can choose one, ask you the maximum radius is how much.
Sol
Two cents +2-sat+tarjan.
First two points to the answer. Then it becomes a 2-sat problem.
Modeling is that \ (i\) if the distance to \ (j\) is more than \ (x*2\), then \ (i\) can only select \ (j\) ^ \ (1\) the Edge, while \ (j\) can only select \ (i\) ^ \ (1\) the edge.
Finally with Tarjan so the next ring, if two points in a ring, then it is not legal.
Code
#include <bits/stdc++.h>using namespace std; #define F first#define S second#define MPR make_pair#define SQR (x) ((x) * (x)) const int N = 205;const double eps = 1e-5;typedef pair< int,int > Pr;typedef pair< pr,pr > Prr;int N,C,CN T,CNTB;PR a[n];vector< int > g[n];int d[n],b[n];int stk[n],instk[n],top;inline int in (int x=0) {scanf ("%d", &x) ; return x; }void CLR () {cntb=cnt=top=0;for (int i=0;i<n;i++) g[i].clear (); memset (d,0,sizeof (d)), memset (b,0,sizeof (b)), memset (instk,0,sizeof (INSTK));} Double Dist (pr x,pr y) {return sqrt ((double) Sqr (X.F-Y.F) +SQR (X.S-Y.S));} void Tarjan (int u,int fa) {d[u]=++cnt,stk[++top]=u,instk[u]=1;int dfsn=cnt;for (int i=0,v;i< (int) g[u].size (); i++) if ((v=g[u][i))!=FA) {if (!d[v]) Tarjan (v,u), if (Instk[v]) d[u]=min (D[u],d[v]);} if (D[U]==DFSN) {for (++cntb;stk[top]!=u;top--) {b[stk[top]]=cntb,instk[stk[top]]=0;} b[stk[top]]=cntb,instk[stk[top--]]=0;} cout<<u<< ":" <<d[u]<< "" <<DFSN<<ENDL;} int check (double x) {CLR (); for (int. i=0;i<c;i++) for (int j=i&1? i+1:i+2;j<c;j++) if (Dist (A[i],a[j]) <x*2) g[i].push_back (j^1), G [J].push_back (I^1);//cout<< "(" <<i<< "," <<j<< ")" <<dist (A[i],a[j]) << endl,for (int i=0;i<c;i++) if (!d[i]) Tarjan (i,i);/*cout<<x<<endl;for (int i=0;i<c;i++) {cout< <i<< ":" <<endl;for (int j=0;j< (int) g[i].size (); j + +) cout<<g[i][j]<< "";cout<< Endl;} for (int i=0;i<c;i++) cout<<b[i]<< "";cout<<endl;cout<< "-------------------------" < <endl;*/for (int i=0;i<c;i++) if (b[i]==b[i^1]) return 0;return 1;} int main () {//freopen ("in.in", "R", stdin), while (~SCANF ("%d", &n)) {c=0;for (int i=1;i<=n;i++) {int x=in (), Y=in () ; A[c++]=mpr (x, y); X=in (), Y=in (); A[c++]=mpr (x, y);} Double L=0.0,r=20000.0,mid;while (R-l > EPs) {mid= (l+r)/2.0;if (check (mid)) L=mid;else R=mid;} printf ("%.2lf\n", mid);} return 0;}
HDU 3622 Bomb Game