poj-openjudge 1043:Bomb! 解题报告
来源:互联网 发布:淘宝黑暗之魂3 编辑:程序博客网 时间:2024/06/05 04:17
题目
2013北大校赛总结
题意:
有很多个炸弹,爆炸半径相同,如果一个爆炸那么所以在爆炸半径内的炸弹也爆炸。
现在要引爆第一个炸弹,使得某个特定的炸弹爆炸,问所需最小的爆炸半径。
解法:
二分爆炸半径,然后BFS是否能炸到要炸的。
Time:120msMemory:2364kBLength:1270 B#include <iostream>#include <cstdio>#include <queue>#include <cmath>#include <cstring>#define EPS 1e-3#define MAXN 510using namespace std;int x[MAXN],y[MAXN];double dist[MAXN][MAXN];bool vi[MAXN];bool check(double len,int n){ queue<int> que; que.push(1); memset(vi,0,sizeof(vi)); while(que.size()) { int now=que.front(); if(now==0) return true; que.pop(); for(int i=0;i<=n;++i) if(!vi[i]&&dist[now][i]<len+EPS) vi[i]=1,que.push(i); } return false;}int main(){ //freopen("C:\\Documents and Settings\\k99\\My Documents\\input.txt","r",stdin); int n,s,t,num; scanf("%d",&n); while(n--) { scanf("%d%d%d",&x[0],&y[0],&num); for(int i=1;i<=num;++i) scanf("%d%d",&x[i],&y[i]); for(int i=0;i<=num;++i) for(int j=0;j<=num;++j) dist[i][j]=sqrt((double)(x[i]-x[j])*(x[i]-x[j])+(double)(y[i]-y[j])*(y[i]-y[j])); double l=0,r=1e18,mid; while(l<r-EPS) { mid=(l+r)/2; if(check(mid,num)) r=mid; else l=mid; } printf("%.2f\n",l); } return 0;}
- poj-openjudge 1043:Bomb! 解题报告
- poj-openjudge 1041 For Short 解题报告
- poj-openjudge 1037:City Metro 解题报告
- poj-openjudge 1042:Moles 解题报告
- openjudge 1835 解题报告
- poj-openjudge 1039:Keine's Problem 解题报告
- poj-openjudge 1040:Bamboo Forest of the Lost 解题报告
- 【Noi OpenJudge】 核电站 解题报告
- [leetcode] 361. Bomb Enemy 解题报告
- [Leetcode] 361. Bomb Enemy 解题报告
- 【解题报告】openjudge poj 数算mooc 第八周 内排序 数组取数
- 【解题报告】poj openjudge 拼写检查 pku数算mooc 检索
- OpenJudge 2745:显示器 解题报告&AC代码
- 【Noi OpenJudge】 算24 解题报告
- poj数百篇解题报告
- poj 1141解题报告
- poj 1001解题报告
- poj 1011 解题报告
- poj-openjudge 1041 For Short 解题报告
- FLEX 界面跳转
- 水仙花
- SecureCRT连接到Linux后使用sqlplus的退格删除
- 分解质因数
- poj-openjudge 1043:Bomb! 解题报告
- 嵌入式系统开发所需要的基础
- JdbcTemplate查询数据 三种callback之间的区别
- Chapter 1. 使用Spring进行数据访问(Data Access With Spring)
- 安卓开发中常见错误1
- spring2.5+hibernate3.3整合时,sessionFactory创建时连接数据库配制的几种方式
- fedora18下配置nginx+php
- 求素数
- oracle数据库创建备份与恢复 脚本