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. 【Foreign】不等式 [数论]

    不等式 Time Limit: 10 Sec  Memory Limit: 128 MB Description 小z热衷于数学. 今天数学课的内容是解不等式:L<=S*x<=R .小z心 ...

  2. 【洛谷 P2756】 飞行员配对方案问题(二分图匹配,最大流)

    题目链接 这不是裸的二分图匹配吗? 而且匈牙利算法自带记录方案.. 但既然是网络流24题,那就用网络流来做吧. 具体就是从源点向左边每个点连一条流量为1的边,两边正常连边,流量都是一,右边所有点向汇点 ...

  3. 【HNOI】 c tree-dp

    [题目描述]给定一个n个节点的树,每个节点有两个属性值a[i],b[i],我们可以在树中选取一个连通块G,这个连通块的值为(Σa[x])(Σb[x]) x∈G,求所有连通块的值的和,输出答案对1000 ...

  4. js_layer弹窗的使用和总结

    2018-04-10 一张呈现给用户的网页,会有很多种交互,比如连不上网络,用户点击按钮时向后台请求数据不成功等等.像这些情况,用户是看不见的, 要给用户更好的体验,在特定的时间,给客户反馈内容.实时 ...

  5. face_recognition 人脸识别报错

    [root@localhost examples]# python facerec_from_video_file.py RuntimeError: module compiled against A ...

  6. skb管理函数之skb_put、skb_push、skb_pull、skb_reserve

    四个操作函数直接的区别,如下图: /** * skb_put - add data to a buffer * @skb: buffer to use * @len: amount of data t ...

  7. Win10下Anaconda3安装CPU版本TensorFlow并使用Pycharm开发

    环境:windows10 软件:Anaconda3 1.安装Anaconda 选择相应的Anaconda进行安装,下载地址点击这里,下载对应系统版本的Anaconda3. 运行 开始菜单->An ...

  8. 利用eclipse调试ofbiz之debug使用

    1.项目右键-配置debug 2.new一个debug调试 3.配置运行类org.ofbiz.base.start.Start 4.设置内存大小:arguments-VM arguments -Xms ...

  9. Redis Cluster 集群使用(3)

    简介 Redis3.0版本之前,可以通过Redis Sentinel(哨兵)来实现高可用(HA),从3.0版本之后,官方推出了Redis Cluster,它的主要用途是实现数据分片(Data Shar ...

  10. jdbc简单小登陆demo

    package com.test; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultS ...