HDU 3622 Bomb Game(2-sat)
Bomb Game
Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3881 Accepted Submission(s): 1346
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.
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <map>
#include <cmath> using namespace std; #define eps 1e-5
const int N = ;
const int M = ; int n , m ; int st[N] , top ;
bool mark[N];
int eh[N] , et[M] , nxt[M] , tot ;
struct node { double x , y ; }e[N]; void init()
{
tot = ;
memset( eh , - , sizeof eh );
memset( mark , false , sizeof mark );
} void addedge( int u , int v ){
et[tot] = v , nxt[tot] = eh[u] , eh[u] = tot ++ ;
et[tot] = u , nxt[tot] = eh[v] , eh[v] = tot ++ ;
} bool dfs( int u )
{
if( mark[u] ) return true;
if( mark[u^] ) return false;
mark[u] = true ;
st[top++] = u ;
for( int i = eh[u] ; ~i ; i = nxt[i] ){
int v = et[i];
if( !dfs(v^) ) return false;
}
return true;
} bool solve()
{
for(int i = ; i < * n ; i += ){
if( !mark[i] && !mark[i+] ){
top = ;
if( !dfs(i) ){
while( top > ) mark[ st[--top] ] = false;
if( !dfs(i+) ) return false ;
}
}
}
return true;
} inline double dis( int i , int j )
{
return sqrt( ( e[i].x - e[j].x ) * ( e[i].x - e[j].x ) + ( e[i].y - e[j].y ) * ( e[i].y - e[j].y ) ) ;
} bool test( double DIS )
{
init();
for( int i = ; i < * n ; i += ){
for( int j = i + ; j < * n ; j += ){
if( dis( i , j ) < DIS )addedge( i , j );
if( dis( i , j^ ) < DIS )addedge( i , j^ );
if( dis( i^ , j ) < DIS )addedge( i^ , j ) ;
if( dis( i^ , j^ ) < DIS )addedge( i^ , j^ );
}
}
return solve();
} int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif // LOCAL
ios::sync_with_stdio(); while( ~scanf("%d",&n) ){
for( int i = ; i < * n ; ++i ){
scanf("%lf%lf",&e[i].x,&e[i].y);
} double l = 0.0 , r = sqrt( pow(20000.0,2.0) + pow(20000.0,2.0) );
while( l + eps <= r ){
double m = ( l + r ) / 2.0 ; if( test(m) )
l = m ;
else
r = m - eps ;
}
printf("%.2lf\n",l/);
}
}
HDU 3622 Bomb Game(2-sat)的更多相关文章
- HDU 3622 Bomb Game(二分+2-SAT)
Bomb Game Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- HDU 5860 Death Sequence(死亡序列)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- HDU 5877 Weak Pair(弱点对)
HDU 5877 Weak Pair(弱点对) Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Jav ...
- HDU 5813 Elegant Construction(优雅建造)
HDU 5813 Elegant Construction(优雅建造) Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65 ...
- HDU 5818 Joint Stacks(联合栈)
HDU 5818 Joint Stacks(联合栈) Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/65536 K (Ja ...
- HDU 2222 Keywords Search(查询关键字)
HDU 2222 Keywords Search(查询关键字) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K ...
- HDU 3549 Flow Problem(最大流)
HDU 3549 Flow Problem(最大流) Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/ ...
- HDU 3622 Bomb Game(2-sat)
HDU 3622 Bomb Game 题目链接 题意:求一个最大半径,使得每一个二元组的点任选一个,能够得到全部圆两两不相交 思路:显然的二分半径,然后2-sat去判定就可以 代码: #include ...
- HDU 4548 美素数(打表)
HDU 4548 美素数(打表)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=88159#problem/H 题目 ...
随机推荐
- k3 cloud套打模板中出现单元格数据为空的情况,及无法正确的选择数据源
解决办法: 找到右边的导航树,点击数据表格选中,然后到左边点击右键,绑定数据
- JS书目推荐(私教推荐)
下面几本书是私教推荐的,从入门到提高,从易到难,想找电子版的可以去下面这个网站找找,挺多书籍的 鸠摩搜书https://www.jiumodiary.com/ JavaScript编程精解 (第二版) ...
- What are draw calls(绘制命令) and what are batches(批)
Resolution It is important to know what are draw calls and what are batches. A draw call is a call t ...
- git 报错
-bash: git: command not found export PATH=$PATH:/usr/local/git/bin 使用git clone出现 fatal: unable to ac ...
- 【Leetcode周赛】从contest-111开始。(一般是10个contest写一篇文章)
Contest 111 (题号941-944)(2019年1月19日,补充题解,主要是943题) 链接:https://leetcode.com/contest/weekly-contest-111 ...
- ltp-ddt smp_basic
SMP_S_FUNC_DUAL_CORE source functions.sh; cmd="stress-ng --matrix 4 -t 10s --perf --matrix-size ...
- Echarts 自定义数据视图
toolbox : { show : true, feature : { dataView : { optionToContent : function(option) { // 行名称 var ax ...
- 【串线篇】Mybatis之缓存原理
所谓二级缓存是名称空间级别的缓存,什么意思呢? TeacherDao.xml首行 <mapper namespace="com.atguigu.dao.TeacherDao" ...
- 【串线篇】Mybatis之模糊查询
TeacherDao.xml sql语句:teacherName like #{name} 测试传值: teacher.setName(“%a%“):
- 9.Markdown语法(自用)——2019年12月12日
title: markdown语法说明 date: "2018-12-26 20:17:16" tags: 技术指令 categories: 技术驿站 markdown语法说明 2 ...