题意:

  就是给出n对坐标,每对只能选一个,以选出来的点为圆心,半径自定义,画圆,而这些圆不能覆盖,求半径最小的圆的最大值

解析:

  看到最x值最x化,那二分变为判定性问题,然后。。。然后我就没想到。。。

  好的吧。。。2-sat 还能在不是一对的两个值之间建边。。。求出连通分量后  看一对中的两个坐标是否在一个连通分量中

在一个说明半径太小 要加大  反之。。反之。

因为涉及小数 要用eps

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <cctype>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#define eps 1e-8
#define rap(i, a, n) for(int i=a; i<=n; i++)
#define rep(i, a, n) for(int i=a; i<n; i++)
#define lap(i, a, n) for(int i=n; i>=a; i--)
#define lep(i, a, n) for(int i=n; i>a; i--)
#define rd(a) scanf("%d", &a)
#define rlld(a) scanf("%lld", &a)
#define rc(a) scanf("%c", &a)
#define rs(a) scanf("%s", a)
#define pd(a) printf("%d\n", a);
#define plld(a) printf("%lld\n", a);
#define pc(a) printf("%c\n", a);
#define ps(a) printf("%s\n", a);
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = 1e5 + , INF = 0x7fffffff, LL_INF = 0x7fffffffffffffff;
int n;
vector<int> G[maxn];
int vis[maxn], low[maxn], scc_clock, scc_cnt, sccno[maxn];
stack<int> S; struct node
{
int x, y;
}Node[maxn]; void dfs(int u)
{
vis[u] = low[u] = ++scc_clock;
S.push(u);
for(int i = ; i < G[u].size(); i++)
{
int v = G[u][i];
if(!vis[v])
{
dfs(v);
low[u] = min(low[u], low[v]);
}
else if(!sccno[v])
{
low[u] = min(low[u], vis[v]);
}
}
if(low[u] == vis[u])
{
scc_cnt++;
for(;;)
{
int x = S.top(); S.pop();
sccno[x] = scc_cnt;
if(x == u) break;
}
}
} double dis(node a, node b)
{
return sqrt((double)(a.x - b.x) * (a.x - b.x) + (double)(a.y - b.y) * (a.y - b.y));
} void build(double mid)
{
for(int i = ; i < maxn; i++) G[i].clear();
for(int i = ; i < n * ; i++)
for(int j = ; j < n * ; j++)
if(i / != j / && dis(Node[i], Node[j]) < mid)
{
G[i].push_back(j ^ ); G[j].push_back(i ^ );
}
} void init()
{
mem(vis, );
mem(low, );
mem(sccno, );
scc_cnt = scc_clock = ;
} bool check()
{
for(int i = ; i < n * ; i += )
{
if(sccno[i] == sccno[i ^ ])
return false;
}
return true;
} int main()
{
while(cin >> n)
{
for(int i = ; i < n; i++)
{
cin >> Node[i << ].x >> Node[i << ].y >> Node[(i << ) + ].x >> Node[(i << ) + ].y;
}
double l = , r = INF;
while(r - l > eps)
{
init();
double mid = l + (r - l) /(double) ;
build(mid * );
for(int i = ; i < n * ; i++)
if(!vis[i]) dfs(i);
if(check()) l = mid;
else r = mid;
}
printf("%.2f\n", l);
} return ;
}

Bomb Game HDU - 3622(二分最小值最大化)的更多相关文章

  1. Halum UVA - 11478(差分约束 + 二分最小值最大化)

    题意: 给定一个有向图,每条边都有一个权值,每次你可以选择一个结点v和一个整数d,把所有以v为终点的边的权值减小d,把所有以v为起点的边的权值增加d,最后要让所有边权的最小值非负且尽量大 两个特判 1 ...

  2. hdu 3622(二分+2-sat判断可行性)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3622 思路:二分是容易想到的,由于题目中有明显的矛盾关系,因此可以用2-sat来验证其可行性.关键是如 ...

  3. poj3258 二分 最小值最大化问题

    River Hopscotch Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 10842   Accepted: 4654 ...

  4. hdu 3622 二分+2-sat

    /* 二分+2-sat 题意:在一个二维平面上给你n个炸弹,和2*n个位置,每一行的两个位置只能有一个放炸弹 现在炸弹爆炸有一个半径,当炸弹爆炸时两个炸弹的半径化成的圆不能相交,求最大半径 二分半径, ...

  5. hdu 3622 二分+2-SAT判定

    思路:如题 #include<iostream> #include<algorithm> #include<cstring> #include<cstdio& ...

  6. Stream My Contest UVA - 11865(带权最小树形图+二分最小值最大化)

    #include <iostream> #include <cstdio> #include <sstream> #include <cstring> ...

  7. HDU 3622 Bomb Game(二分+2-SAT)

    Bomb Game Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  8. HDU 3622 Bomb Game(2-sat)

    HDU 3622 Bomb Game 题目链接 题意:求一个最大半径,使得每一个二元组的点任选一个,能够得到全部圆两两不相交 思路:显然的二分半径,然后2-sat去判定就可以 代码: #include ...

  9. codeforce 1070 E Getting Deals Done(二分求最大化最小值)

    Polycarp has a lot of work to do. Recently he has learned a new time management rule: "if a tas ...

随机推荐

  1. i++ 相比 ++i 哪个更高效?为什么?

    ++i的效率高些,++i在运算过程中不产生临时对象,返回的就是i,是个左值,类似++i=1这样的表达式是合法的,而i++在运算的过程中会产生临时对象,返回的是零时对象的值,是个右值,像i++=1这样的 ...

  2. [LeetCode] 56 - Merge Intervals 合并区间

    Given a collection of intervals, merge all overlapping intervals. For example,Given [1,3],[2,6],[8,1 ...

  3. JavaWeb连接SQLServer数据库并完成一个登录界面及其功能设计。

    一.JDBC连接SQLserver数据库的步骤: 1.下载SQLserver的JDBC驱动文件——Microsoft JDBC Driver 4.0 for SQL Server 2.例如下载得到的文 ...

  4. CodeIgniter框架中尝试使用swoole

    ci框架版本:3.1.7.     swoole版本:1.7.      php版本:5.6 相关文档: 以cli方式运行ci框架 swoole官方手册 创建一个TestSwoole和Hello控制器 ...

  5. 局域网 服务器 https

    局域网内搭建一个服务器,可以使用 https 吗 - V2EXhttps://www.v2ex.com/t/472394 局域网内多台机器使用自签发证书架设https网站二:实施 - 左直拳的马桶_日 ...

  6. centos6 yum 安装memcached

    centos6 yum 安装memcached - 像块石头 - 博客园http://www.cnblogs.com/rockee/archive/2012/08/01/2619160.html yu ...

  7. 一、npm基础

    一.什么是npm? npm 是模块管理工具,可以下载.更新第三方模块,也可以发布自己的模块共替他人使用,主要目的在于分享和重用代码: 二.下载安装node,更新npm node 下载网址  https ...

  8. C\C++学习笔记 2

    C++记录4 自动存储: 生命周期在代码块,存储在栈,后入先出. 静态存储: 存在于程序的整个周期. 动态存储: 使用new delete 在内存池(堆)存储,不受程序生命周期控制. 内存泄露: 没有 ...

  9. asp.net core下一个简单的分页技术

    在做web应用的时候免不了要对数据进行分页,我最近在做asp.net core的开发的时候就遇到了这个需求,现在简单的记录一下: public class PaginatedList<T> ...

  10. Windows环境下在IDEA编辑器中spark开发安装步骤

    以下是windows环境下安装spark的过程: 1.安装JDK(version:1.8.0.152) 2.安装scala(version:2.11/2.12) 3.安装spark(version:s ...