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

二分答案转化成2-sat问题。

上午测试时总想二分后把它转化成最大点独立集但是不会写最大点独立集暴力又秘制写错所以就爆零啦~~~

#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; const int N = 503; double x[N << 1], y[N << 1], dis[N << 1][N << 1];
double sqr(double x) {return x * x;} struct node {int nxt, to;} E[N * N];
int bel[N << 1], dfn[N << 1], low[N << 1], dfn_cnt;
int st[N << 1], top = 0, cnt, point[N << 1], dn, n, col_tot;
bool inst[N << 1]; void ins(int u, int v) {E[++cnt] = (node) {point[u], v}; point[u] = cnt;} void tarjan(int u) {
dfn[u] = low[u] = ++dfn_cnt;
inst[st[++top] = u] = true;
if (u == 11) {
++u; --u;
}
for (int i = point[u]; i; i = E[i].nxt) {
if (!dfn[E[i].to]) tarjan(E[i].to), low[u] = min(low[u], low[E[i].to]);
else if (inst[E[i].to]) low[u] = min(low[u], dfn[E[i].to]);
}
if (dfn[u] == low[u]) {
++col_tot;
while (st[top] != u) {
inst[st[top]] = false;
bel[st[top--]] = col_tot;
}
inst[u] = false; bel[u] = col_tot; --top;
}
} bool can(double num) {
cnt = 0;
memset(point, 0, sizeof(int) * dn);
for (int i = 0; i < dn; ++i)
for (int j = i + 1; j < dn; ++j)
if (j - i != n && dis[i][j] < num)
ins(i, (j + n) % dn), ins(j, (i + n) % dn); dfn_cnt = col_tot = 0;
memset(dfn, 0, sizeof(int) * dn);
for (int i = 0; i < dn; ++i)
if (dfn[i] == 0) tarjan(i); for (int i = 0; i < n; ++i)
if (bel[i] == bel[i + n])
return false;
return true;
} int main() {
while (~scanf("%d", &n)) {
for (int i = 0; i < n; ++i)
scanf("%lf%lf%lf%lf", x + i, y + i, x + n + i, y + n + i); dn = n << 1;
for (int i = 0; i < dn; ++i)
for (int j = i + 1; j < dn; ++j)
if (j - i != n)
dis[i][j] = dis[j][i] = sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j])); double left = 0, right = 22000, mid;
while (right - left > 1e-5) {
mid = (left + right) / 2;
if (can(mid)) left = mid;
else right = mid;
}
printf("%.2lf\n", left / 2);
}
return 0;
}

【HDU 3622】Bomb Game的更多相关文章

  1. 【HDU 3555】 Bomb

    [题目链接] 点击打开链接 [算法] 数位DP [代码] #include<bits/stdc++.h> using namespace std; #define MAXL 15 type ...

  2. 【HDU 5934】Bomb(强连通缩点)

    Problem Description There are N bombs needing exploding. Each bomb has three attributes: exploding r ...

  3. 【数位dp】【HDU 3555】【HDU 2089】数位DP入门题

    [HDU  3555]原题直通车: 代码: // 31MS 900K 909 B G++ #include<iostream> #include<cstdio> #includ ...

  4. 【HDU 5647】DZY Loves Connecting(树DP)

    pid=5647">[HDU 5647]DZY Loves Connecting(树DP) DZY Loves Connecting Time Limit: 4000/2000 MS ...

  5. -【线性基】【BZOJ 2460】【BZOJ 2115】【HDU 3949】

    [把三道我做过的线性基题目放在一起总结一下,代码都挺简单,主要就是贪心思想和异或的高斯消元] [然后把网上的讲解归纳一下] 1.线性基: 若干数的线性基是一组数a1,a2,a3...an,其中ax的最 ...

  6. 【HDU 2196】 Computer(树的直径)

    [HDU 2196] Computer(树的直径) 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 这题可以用树形DP解决,自然也可以用最直观的方法解 ...

  7. 【HDU 2196】 Computer (树形DP)

    [HDU 2196] Computer 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 刘汝佳<算法竞赛入门经典>P282页留下了这个问题 ...

  8. 【HDU 5145】 NPY and girls(组合+莫队)

    pid=5145">[HDU 5145] NPY and girls(组合+莫队) NPY and girls Time Limit: 8000/4000 MS (Java/Other ...

  9. 【hdu 1043】Eight

    [题目链接]:http://acm.hdu.edu.cn/showproblem.php?pid=1043 [题意] 会给你很多组数据; 让你输出这组数据到目标状态的具体步骤; [题解] 从12345 ...

随机推荐

  1. 关于scala 集合 List Map Set

    1,数组 2,List,ListBuffer 3, Map , mutable.Map

  2. 大聊Python----多线程

    Python里的多线程是假的多线程,不管有多少核,同一时间只能在一个核中进行操作!利用Python的多线程,只是利用CPU上下文切换的优势,看上去像是并发,其实只是个单线程,所以说他是假的单线程. 那 ...

  3. bzoj 1004 burnside 引理+DP

    对于burnside引理需要枚举染色,这道题属于burnside的一种简单求解的方法,就是polya,我们可以使每一种置换中的循环节中的元素的颜色都相同,那么这样的话就可以直接DP了,我们可以将m个置 ...

  4. Vue 双向绑定原理

    Vue.js最核心的功能有两个,一是响应式的数据绑定系统,二是组件系统. 一.访问器属性:Object.defineProperty ECMAScript 262v5带来的新东西,FF把它归入为jav ...

  5. php中的parse_ini_file函数

    作用:parse_ini_file() 函数解析一个配置文件,并以数组的形式返回其中的设置 格式:parse_ini_file(file,true)// (第二个参数为可选参数.如果设置为 true, ...

  6. KVM虚拟机建立快照

    部分转载: http://blog.csdn.net/gg296231363/article/details/6899533 windows虚拟机默认镜像格式为raw,快照默认格式为qcow2.win ...

  7. win7下安装Linux实现双系统全攻略

    http://jingyan.baidu.com/article/c275f6bacc3326e33c756743.html

  8. python基础===时间处理模块

    时间模块 Python中有很多方便我们处理时间信息的模块 time 模块 datetime 模块 pytz 模块 dateutil 模块 这里我们着重介绍的是前两种 time模块 time.time( ...

  9. 文字顺时针旋转90度(纵向)&古诗词排版

    1.文字旋转90度 width: 100px; height: 200px; line-height: 100px; text-align: center; writing-mode: vertica ...

  10. 分割线用CSS样式做出来的效果

    一:单个标签实现分隔线:. ; ; line-height: 1px; border-left: 200px solid #ddd; border-right: 200px solid #ddd; t ...