http://acm.hdu.edu.cn/showproblem.php?pid=3622

又是各种逗。。

2-SAT是一种二元约束,每个点可以置于两种状态,但只能处于一种状态,然后图是否有解就是2-SAT啦。

看白书吧。

这个图的边的概念一定要弄懂!以下的x'表示x的另一个点

边(x, y)表示取了x就一定取y,x是前提条件!

对于约束(x, y),取x但不取y,那么显然连边(x, y'), (y, x'),这个意思一定要懂,就是说取了x就取y的另一个,可以唯一确定;那么反之取了y就一定取x的另一个(这里一定不是(x', y),因为x'是由y决定而不是y由x'决定)=

upd:我不知道前边在说什么,,,其实很简单的,对于两个状态x和y,假设我们要满足(x=1 或 y=0),那么显然当x=0时要满足这个性质,那么y只能=0。反之亦然。所以就是连边x0->y0, y1->x1。这题也是同理,对于状态x和y,如果x1和y1不能撮合,那么就连边x0->y1, y0->x1,这是因为我们必须要满足取一个,即(x=1 或 y=1),至少取一个,那么当x=0时,就只能连y1,(当然不考虑x0和y1冲突,因为我们分两次建图。。。如果到最后冲突,说明无解)

sigh..

这篇博文讲得十分详细orz http://www.cnblogs.com/kuangbin/archive/2012/10/05/2712429.html

白书上写的是dfs求,还有一种是tarjan缩点求。。

我暂时写白书的。。

本题只要二分半径然后连边即可。

#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define read(a) a=getint()
#define print(a) printf("%d", a)
#define dbg(x) cout << (#x) << " = " << (x) << endl
#define printarr2(a, b, c) for1(_, 1, b) { for1(__, 1, c) cout << a[_][__]; cout << endl; }
#define printarr1(a, b) for1(_, 1, b) cout << a[_] << '\t'; cout << endl
inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; }
inline const int max(const int &a, const int &b) { return a>b?a:b; }
inline const int min(const int &a, const int &b) { return a<b?a:b; } const int N=215;
const double eps=1e-4;
int n, nn, x[N], y[N], vis[N], s[N], ihead[N], cnt, top;
struct ED { int to, next; }e[(N*N)<<1];
void add(int u, int v) { e[++cnt].next=ihead[u]; ihead[u]=cnt; e[cnt].to=v; }
bool dfs(int u) {
if(vis[u]) return true;
if(vis[u^1]) return false;
vis[u]=true; s[++top]=u;
for(int i=ihead[u]; i; i=e[i].next) if(!dfs(e[i].to)) return false;
return true;
}
bool check(double r) {
CC(ihead, 0); cnt=0; CC(vis, 0);
double dis=(r*r)*4;
for1(i, 2, nn) {
int t; if(i&1) t=i+1; else t=i+2;
for1(j, t, nn) {
double x1=x[i], y1=y[i], x2=x[j], y2=y[j];
double rg=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
if(rg<dis) add(i, j^1), add(j, i^1);
}
}
for(int i=2; i<nn; i+=2) if(!vis[i] && !vis[i+1]) {
top=0;
if(!dfs(i)) {
while(top) vis[s[top--]]=0;
if(!dfs(i+1)) return false;
}
}
return true;
} int main() {
while(~scanf("%d", &n)) {
for1(i, 1, n) rep(j, 2) read(x[(i<<1)+j]), read(y[(i<<1)+j]); nn=(n<<1)+1;
double l=0, r=50000;
while(r-l>eps) {
double m=(l+r)/2;
if(check(m)) l=m;
else r=m;
}
printf("%.2lf\n", l);
}
return 0;
}

Problem Description
Robbie is playing an interesting computer game. The game field is an unbounded 2-dimensional region. There are N rounds in the game. At each round, the computer will give Robbie two places, and Robbie should 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 should 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.
 
Input
The
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, 10000].
 
Output
Output
one float number for each test case, indicating the best possible
score. The result should be rounded to two decimal places.
 
Sample Input
2
1 1 1 -1
-1 -1 -1 1
2
1 1 -1 -1
1 -1 -1 1
 
Sample Output
1.41
1.00
 
Source
 
Recommend
lcy   |   We have carefully selected several similar problems for you:  3625 3628 3629 3627 3621

【HDU】3622 Bomb Game(2-SAT)的更多相关文章

  1. 【HDU】I love sneakers!(分组背包)

    看了许多的题解,都有题目翻译,很不错,以后我也这样写.直接翻译样例: /*鞋子的数量N[1, 100]; 拥有的金钱M[1, 1w]; 品牌数目[1, 10]*/ /*以下四行是对于每双鞋的描述*/ ...

  2. 【HDU】5248-序列变换(贪心+二分)

    二分枚举长度改变的长度即可了 #include<cstdio> #include<cstring> #include<algorithm> using namesp ...

  3. 【HDU】2222 Keywords Search(AC自动机)

    题目 传送门:QWQ 分析 $ AC $自动机模板,黈力的码风真的棒极了,这是我抄他的. 还有 题号不错 代码 #include <cstdio> #include <cstring ...

  4. 【HDU】1520 Anniversary party(树形dp)

    题目 题目 分析 带权值的树上最大独立集 代码 #include <bits/stdc++.h> using namespace std; ; int a[maxn], n, fa[max ...

  5. 【HDU1693】Eat the Trees(插头dp)

    [HDU1693]Eat the Trees(插头dp) 题面 HDU Vjudge 大概就是网格图上有些点不能走,现在要找到若干条不相交的哈密顿回路使得所有格子都恰好被走过一遍. 题解 这题的弱化版 ...

  6. SSAS系列——【07】多维数据(查询Cube)

    原文:SSAS系列——[07]多维数据(查询Cube) 1.什么是MDX? MDX叫做"多维表达式",是一种查询语言,是一种和SQL类似的查询语言,它基于 XML for Anal ...

  7. SSAS系列——【06】多维数据(创建Cube)

    原文:SSAS系列--[06]多维数据(创建Cube) 1.文件类型说明 项目定义文件 (.dwproj).项目用户设置 (.dwproj.user).数据源文件 (.ds).数据源视图文件 (.ds ...

  8. SSAS系列——【04】多维数据(物理体系结构)

    原文:SSAS系列——[04]多维数据(物理体系结构) 1.本地多维数据集 本地多维数据集和本地挖掘模型允许在客户端工作站与网络的连接断开时对该工作站进行分析.在与本地多维数据集进行交互时,ADMOD ...

  9. SSAS系列——【05】多维数据(编程体系结构)

    原文:SSAS系列--[05]多维数据(编程体系结构) 1.什么是AMO? 翻译:AMO是SSAS中一个完整的管理类集合,它在Microsoft.AnalysisServices命名空间下,我们可以在 ...

随机推荐

  1. MFC用代码加入对话框背景图片和button图片

    执行环境:VS2013 一.加入对话框背景图片 ①插入位图,把生成的空白位图进行替换(xxx.bmp图片的名称和格式与生成的空白位图保持一致) ②查看属性,得到位图ID ③编写代码: void CMF ...

  2. 算法笔记_040:二进制幂(Java)

    目录 1 问题描述 2 解决方案 2.1 从左至右二进制幂 2.2 从右至左二进制幂   1 问题描述 使用n的二进制表示,计算a的n次方. 2 解决方案 2.1 从左至右二进制幂 此方法计算a的n次 ...

  3. CLightLock:一个简单AutoLock

    原理: 标准的RAII, 利用构造函数进行加锁,利用析构函数进行解锁. #ifndef _C_LIGTHT_LOCK_HPP #define _C_LIGTHT_LOCK_HPP class CLig ...

  4. mosquitto 启动命令

    启动命令 mosquitto [-c config file] [ -d | --daemon ] [-p port number] [-v] -c 后面跟的是启动mosquitto可以调整的参数,比 ...

  5. Python3.2官方文档翻译--输出格式化

    第八章 标准库二 第二部分涵盖了很多更能满足专业开发者需求的高级模块.这些模块在小脚本中非常少出现. 8.1 输出格式化 Reprlib模块为大型的或深度嵌套的容器缩写显示提供了repr()函数的一个 ...

  6. 连接oracle时报错:ORA-28001: the password has expired

    调试Web项目的时候出现异常: java.sql.SQLException: ORA-28001: the password has expired 网上查了一下,是Oracle11g密码过期的原因 ...

  7. unity5, 在unity中编辑动画

    如图,dock是一个空gameObject,其下包含mouth_dn,mouth_up (应该叫lip_dn,lip_up更合适,这不是重点,先不改了),head,eye_left,eye_right ...

  8. getconf命令【一天一个命令】

    我们时常需要查询系统相关的信息,比如页面大小,整数大小之类,如果编写程序去计算会比较繁琐,这里有一个很有用的命令,可以用来获取系统相关信息.它就是getconf.   $ getconf PAGE_S ...

  9. Atitit.web预览播放视频的总结

    Atitit.web预览播放视频的总结 1. 浏览器类型的兼容性(chrome,ff,ie) 1 2. 操作系统的兼容性 1 3. 视频格式的内部视频格式跟播放器插件的兼容性.. 2 4. 指定播放器 ...

  10. Cocos2d-x 3.x 如何编译成安卓程序

    1.安装JDK 2.安装eclipse,安卓官方现在不提供eclipse for android,只好自己配置了.首先安装一个eclipse,在Help——Install New SoftWare中安 ...