【HDU 3622】Bomb Game
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的更多相关文章
- 【HDU 3555】 Bomb
[题目链接] 点击打开链接 [算法] 数位DP [代码] #include<bits/stdc++.h> using namespace std; #define MAXL 15 type ...
- 【HDU 5934】Bomb(强连通缩点)
Problem Description There are N bombs needing exploding. Each bomb has three attributes: exploding r ...
- 【数位dp】【HDU 3555】【HDU 2089】数位DP入门题
[HDU 3555]原题直通车: 代码: // 31MS 900K 909 B G++ #include<iostream> #include<cstdio> #includ ...
- 【HDU 5647】DZY Loves Connecting(树DP)
pid=5647">[HDU 5647]DZY Loves Connecting(树DP) DZY Loves Connecting Time Limit: 4000/2000 MS ...
- -【线性基】【BZOJ 2460】【BZOJ 2115】【HDU 3949】
[把三道我做过的线性基题目放在一起总结一下,代码都挺简单,主要就是贪心思想和异或的高斯消元] [然后把网上的讲解归纳一下] 1.线性基: 若干数的线性基是一组数a1,a2,a3...an,其中ax的最 ...
- 【HDU 2196】 Computer(树的直径)
[HDU 2196] Computer(树的直径) 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 这题可以用树形DP解决,自然也可以用最直观的方法解 ...
- 【HDU 2196】 Computer (树形DP)
[HDU 2196] Computer 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 刘汝佳<算法竞赛入门经典>P282页留下了这个问题 ...
- 【HDU 5145】 NPY and girls(组合+莫队)
pid=5145">[HDU 5145] NPY and girls(组合+莫队) NPY and girls Time Limit: 8000/4000 MS (Java/Other ...
- 【hdu 1043】Eight
[题目链接]:http://acm.hdu.edu.cn/showproblem.php?pid=1043 [题意] 会给你很多组数据; 让你输出这组数据到目标状态的具体步骤; [题解] 从12345 ...
随机推荐
- 【Dream Counting, 2006 Dec-数数的梦】数位dp
题意:给定两个数,问区间[A,B]中0~9分别出现了多少次.A,B<=10^18 题解:应该是最裸的数位dp吧..一开始没有记忆化tle了TAT 我们可以求出区间[0,B]的,再减去区间[0,A ...
- Can you answer these queries?(HDU4027+势能线段树)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4027 题目: 题意:n个数,每次区间更新将其数值变成它的根号倍(向下取整),区间查询数值和. 思路:易 ...
- Vue 键盘事件
Vue2键盘事件:keydown/keyup... 1.使用 <!DOCTYPE html> <html> <head> <title></tit ...
- Python3安装Celery模块后执行Celery命令报错
1 Python3安装Celery模块后执行Celery命令报错 pip3 install celery # 安装正常,但是执行celery 命令的时候提示没有_ssl模块什么的 手动在Python解 ...
- Composer 手动安装
Linux/Mac 环境 sudo wget -O /usr/local/bin/composer https://dl.laravel-china.org/composer.phar sudo ch ...
- ftrace 简介【转】
转自:http://www.ibm.com/developerworks/cn/linux/l-cn-ftrace/index.html Trace 对于软件的维护和性能分析至关重要,ftrace 是 ...
- 1003: FFF团的情侣活动--课程作业--找出N个数字中唯一出现奇数次的数
1003: FFF团的情侣活动 Time Limit: 1 Sec Memory Limit: 2 MB Description 圣诞节快到了,Water作为大FFF团团长,组织许多对情侣进行电影院 ...
- hadoop中setOutputKeyClass和setOutputValueClass里类型
初学mapreduce programing,纠结一天的问题如下: job.setOutputKeyClass和job.setOutputValueClas在默认情况下是同时设置map阶段和reduc ...
- hadoop-Rpc使用实例
代码:https://github.com/xufeng79x/hadoop-common-rpc-demo 1. 简介 hadoop中使用rpc机制来进行分布式进程间的通信,被封装进了hadoop- ...
- MySQL查找出重复的记录
问题 查找表中多余的重复记录,重复记录是根据单个字段来判断的.例如:有张表中有uid和uname两个字段,现在需要查找出uname重复的所有数据列.数据表如下: id o_id uname 1 11 ...