HDU3622 Bomb Game
来源:互联网 发布:技术推算法的步骤 编辑:程序博客网 时间:2024/06/10 23:18
Bomb Game
Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5718 Accepted Submission(s): 2071
Problem Description
Robbie is playing an interesting computer game. The game field is an unbounded 2-dimensional region. There are N rounds in the game. At each round, the computer will give Robbie two places, and Robbie should choose one of them to put a bomb. The explosion area of the bomb is a circle whose center is just the chosen place. Robbie can control the power of the bomb, that is, he can control the radius of each circle. A strange requirement is that there should be no common area for any two circles. The final score is the minimum radius of all the N circles.
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.
Input
The first line of each test case is an integer N (2 <= N <= 100), indicating the number of rounds. Then N lines follow. The i-th line contains four integers x1i, y1i, x2i, y2i, indicating that the coordinates of the two candidate places of the i-th round are (x1i, y1i) and (x2i, y2i). All the coordinates are in the range [-10000, 10000].
Output
Output one float number for each test case, indicating the best possible score. The result should be rounded to two decimal places.
Sample Input
2
1 1 1 -1
-1 -1 -1 1
2
1 1 -1 -1
1 -1 -1 1
Sample Output
1.41
1.00
Source
2010 Asia Regional Tianjin Site —— Online Contest
题目的意思是给出n对炸弹的位置,每对只能引爆1个,引爆的炸弹不能互相炸到,求最大爆炸半径
思路:二分+2-sat 根据枚举的距离矛盾关系建图,然后2-sat判断
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include <cmath> #include <map> #include <set> #include <stack> #include <queue> #include <vector> #include <bitset> using namespace std;#define LL long long const int INF = 0x3f3f3f3f;#define MAXN 100100 #define MAXM 5000100 struct node{ int u, v, next;} edge[MAXM];int dfn[MAXN], low[MAXN], s[MAXN], Stack[MAXN], in[MAXN], block[MAXN],x[MAXN],y[MAXN];int cnt, tot, index, bnum, ctt;void init(){ memset(s, -1, sizeof s); memset(dfn, 0, sizeof dfn); memset(low, 0, sizeof low); memset(Stack, 0, sizeof Stack); memset(in, 0, sizeof in); memset(block, 0, sizeof block); cnt = tot = index = bnum = 0;}void add(int u, int v){ edge[cnt].u = u; edge[cnt].v = v; edge[cnt].next = s[u]; s[u] = cnt++;}void tarjan(int x){ dfn[x] = low[x] = ++tot; Stack[++index] = x; in[x] = 1; for (int i = s[x]; ~i; i = edge[i].next) { int v = edge[i].v; if (!dfn[v]) { tarjan(v); low[x] = min(low[x], low[v]); } else if (in[v]) { low[x] = min(low[x], low[v]); } } if (dfn[x] == low[x]) { bnum++; do { //printf("%d ",Stack[index]); block[Stack[index]] = bnum; in[Stack[index--]] = 0; } while (Stack[index + 1] != x); // printf("\n"); }}bool solve(){ for (int i = 0; i < ctt; i++) if (!dfn[i]) tarjan(i); for (int i = 0; i < ctt; i += 2) { if (block[i] == block[i ^ 1]) return 0; } return 1;}double calcdis(int xx1, int yy1, int xx2, int yy2){ return sqrt((xx1 - xx2)*(xx1 - xx2) + (yy1 - yy2)*(yy1 - yy2));}int main(){ int n; while (~scanf("%d", &n)) { ctt = 2 * n; for (int i = 0; i < n; i++) { scanf("%d%d%d%d",& x[2 * i], &y[2 * i], &x[2 * i + 1], &y[2 * i + 1]); } double l = 0, r = 1000000; while (r - l > 1e-7) { double mid = (l + r) / 2; init(); for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { int a = 2 * i, b = 2 * j; if (calcdis(x[a], y[a], x[b], y[b]) < 2*mid) { add(a, b ^ 1); add(b, a ^ 1); } if (calcdis(x[a], y[a], x[b^1], y[b^1]) < 2*mid) { add(a, b); add(b^1, a ^ 1); } if (calcdis(x[a^1], y[a^1], x[b], y[b]) < 2*mid) { add(a^1, b ^ 1); add(b, a ); } if (calcdis(x[a^1], y[a^1], x[b^1], y[b^1]) < 2*mid) { add(a^1, b); add(b^1, a); } } } if (solve()) l = mid; else r = mid; } printf("%.2f\n",l); } return 0;}
- HDU3622 Bomb Game
- HDU3622 Bomb Game
- [HDU3622][2-sat]Bomb Game
- hdu3622 Bomb Game(二分+2-SAT)
- HDU3622-Bomb Game(2-SAT+二分)
- hdu3622 Bomb Game--2-sat & 二分
- [HDU3622]Bomb Game(2-SAT)
- [二分 + 2-SAT] HDU3622: Bomb Game
- 【HDU3622】Bomb Game-二分答案+2-SAT
- hdu3622 Bomb Game(2分答案+2sat判定)
- HDU3622 Bomb Game(2-SAT 问题,The 35th ACM/ICPC Asia Regional Tianjin ,Online)
- HDU3622.Bomb Game——2-sat二分最大值+可行性判定
- Bomb Game
- HDU3622
- hdoj 3622 Bomb Game
- hdu 2873 Bomb Game
- hdu 2873 Bomb Game
- hdu2873 Bomb Game-----sg
- c#构造函数<一>子类调用父类构造函数
- 使用lidar360和arcgis生成DEM渲染图
- Python爬虫爬取京东内存条数据并作简单分析
- 使用ISO镜像文件在VMware虚拟机中安装系统
- Run-Down 保护
- HDU3622 Bomb Game
- spring框架-基本jar包作用
- 使用FormatMessage函数编写一个内核错误码查看器
- Microsoft Virtual PC2007的安装配置
- poj题目清单(一)
- 实验二 线性表综合实验——单链表
- push was rejected by remote(因部分文件过大)(安卓)
- PL/SQL之四 触发器
- 习题7-15:最大的数(dfs+最优性剪枝)