分析:这道题实在是不好想,一个可以骗分的想法是假定要求的那个点在中心点上,可以骗得不少分.但是在边上的点要怎么确定呢?理论复杂度O(﹢无穷).答案一定是和端点有关的,涉及到最大值最小,考虑二分最大值,关键就是怎么check.如果有一条边x,还有一个点y,把y到x上的点的距离>mid的点给标记上,这样就会形成许多个区间,判断一下x是否被这些区间给完全覆盖住了,如果没有被完全覆盖住,证明这个最大值可以更小.思路非常奇妙,具体实现细节可以参看代码:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; const int maxn = , maxm = ; int n, m, a[maxn][maxn], head[maxn], to[maxm],ans,len,top,nextt[maxm],w[maxm], tot = ;
struct node
{
int x, y, z;
}e[]; struct node2
{
int first, second;
}e2[]; void add(int x, int y, int z)
{
w[tot] = z;
to[tot] = y;
nextt[tot] = head[x];
head[x] = tot++;
} void floyd()
{
for (int k = ; k <= n; k++)
for (int i = ; i <= n; i++)
for (int j = ; j <= n; j++)
if (a[i][j] > a[i][k] + a[k][j])
a[i][j] = a[i][k] + a[k][j];
} void add2(int x, int y)
{
e2[++top].first = x;
e2[top].second = y;
} bool cmp(node2 a, node2 b)
{
if (a.first == b.first)
return a.second < b.second;
return a.first < b.first;
} bool can()
{
int x = ;
sort(e2 + , e2 + + top,cmp);
for (int i = ; i <= top; i++)
{
if (x < e2[i].first)
return false;
if (x > e2[i].second)
continue;
x = e2[i].second + ;
}
if (x > len)
return true;
return false;
} bool check(int p)
{
bool flag = false;
for (int i = ; i <= m; i++)
{
top = ;
len = e[i].z;
for (int j = ; j <= n; j++)
{
int x = p - a[e[i].x][j];
int y = p - a[e[i].y][j];
if (x < && y < )
{
add2(, e[i].z);
break;
}
if (x >= e[i].z || y >= e[i].z)
continue;
if (x + y >= e[i].z)
continue;
add2(max(, x + ), min(e[i].z, e[i].z - y - ));
}
if (!can())
flag = ;
if (flag)
break;
}
if (flag)
return true;
return false;
} int main()
{
memset(a, / , sizeof(a));
scanf("%d%d", &n, &m);
for (int i = ; i <= m; i++)
{
int u, v, z;
scanf("%d%d%d", &u, &v, &z);
z *= ;
add(u, v, z);
add(v, u, z);
e[i].x = u;
e[i].y = v;
e[i].z = z;
a[u][v] = a[v][u] = min(a[u][v], z);
}
for (int i = ; i <= n; i++)
a[i][i] = ;
floyd();
int l = , r = ;
while (l <= r)
{
int mid = (l + r) >> ;
if (check(mid))
{
ans = mid;
r = mid - ;
}
else
l = mid + ;
}
double temp = ans / 2.0;
printf("%.2lf\n", temp);
return ;
}

noip模拟赛 radius的更多相关文章

  1. NOIP模拟赛20161022

    NOIP模拟赛2016-10-22 题目名 东风谷早苗 西行寺幽幽子 琪露诺 上白泽慧音 源文件 robot.cpp/c/pas spring.cpp/c/pas iceroad.cpp/c/pas ...

  2. contesthunter暑假NOIP模拟赛第一场题解

    contesthunter暑假NOIP模拟赛#1题解: 第一题:杯具大派送 水题.枚举A,B的公约数即可. #include <algorithm> #include <cmath& ...

  3. NOIP模拟赛 by hzwer

    2015年10月04日NOIP模拟赛 by hzwer    (这是小奇=> 小奇挖矿2(mining) [题目背景] 小奇飞船的钻头开启了无限耐久+精准采集模式!这次它要将原矿运到泛光之源的矿 ...

  4. 大家AK杯 灰天飞雁NOIP模拟赛题解/数据/标程

    数据 http://files.cnblogs.com/htfy/data.zip 简要题解 桌球碰撞 纯模拟,注意一开始就在袋口和v=0的情况.v和坐标可以是小数.为保险起见最好用extended/ ...

  5. 队爷的讲学计划 CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的讲学计划 题解:刚开始理解题意理解了好半天,然后发 ...

  6. 队爷的Au Plan CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的Au%20Plan 题解:看了题之后觉得肯定是DP ...

  7. 队爷的新书 CH Round #59 - OrzCC杯NOIP模拟赛day1

    题目:http://ch.ezoj.tk/contest/CH%20Round%20%2359%20-%20OrzCC杯NOIP模拟赛day1/队爷的新书 题解:看到这题就想到了 poetize 的封 ...

  8. CH Round #58 - OrzCC杯noip模拟赛day2

    A:颜色问题 题目:http://ch.ezoj.tk/contest/CH%20Round%20%2358%20-%20OrzCC杯noip模拟赛day2/颜色问题 题解:算一下每个仆人到它的目的地 ...

  9. CH Round #52 - Thinking Bear #1 (NOIP模拟赛)

    A.拆地毯 题目:http://www.contesthunter.org/contest/CH%20Round%20%2352%20-%20Thinking%20Bear%20%231%20(NOI ...

随机推荐

  1. bzoj1227

    离散化+树状数组+排列组合 很久以前就看到过这道题,现在依然不会做...看完题解发现思路很简单,就是有点难写 我们先将坐标离散化,x和y最大是w,然后我们就有了一个暴力做法, 枚举每块墓地,统计,因为 ...

  2. C# Pen绘制虚线(System.Drawing.Pen与System.Windows.Media.Pen)

    一.绘制虚线的方法 GDI绘制,使用的是System.Drawing.Pen Pen pen = new Pen(Color.Red, 1);            pen.DashStyle = S ...

  3. MFC学习篇(一):用OpenCV显示视频

    首先是一些基础的步骤,如建立MFC应用,添加按钮等,博主主要参考了下面这篇文章,其中的前32步都是用OpenCV显示图片和视频所必须的,即通用的.由于LZ原来有配置OpenCV的基础,所以配制还是比较 ...

  4. 数字签名与数字证书以及https

    数字签名与数字证书以及httpshttps://blog.csdn.net/lzghxjt/article/details/79604602

  5. java学习笔记_BeatBox(GUI部分)

    import java.awt.*; import javax.swing.*; public class BeatBox { JFrame theFrame; JPanel mainPanel; S ...

  6. JS——标记

    continue 语句(带有或不带标签引用)只能用在循环中.break 语句(不带标签引用),只能用在循环或 switch 中.通过标签引用,break 语句可用于跳出任何 JavaScript 代码 ...

  7. nested exception is java.io.FileNotFoundException: class path resource [jdbc.properties] cannot be opened because it does not exist

    Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [j ...

  8. VC++ 遍历文件夹

    }; strcpy_s(szFind, MAX_PATH, m_szDir); strcat_s(szFind, "\\*.*"); WIN32_FIND_DATA wfd; HA ...

  9. Kafka 入门和 Spring Boot 集成

    目录 Kafka 入门和 Spring Boot 集成 标签:博客 概述 应用场景 基本概念 基本结构 和Spring Boot 集成 集成概述 集成环境 kafka 环境搭建 Spring Boot ...

  10. dom4j.jar 的调试方法

    1.将jar包的路径写在 classpath下 在cmd窗口中,查看 classpath的内容是否已经加上该路径,win7 下cmd窗口一定要是管理员身份执行 2.在D盘新建一个DOM4JWriter ...