/*
可以发现, 最优路径上的所有拐点, 基本上都满足一定的性质, 也就是说是在矩形上的拐角处
所以我们可以把他们提出来, 单独判断即可 由于我们提出来的不超过2n + 2个点, 我们将其按照x坐标排序, 这样就只能单方向走
n^2枚举判断两个点之间能不能直接走, 然后连边DAGdp即可 */ #include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<cmath>
#include<iostream>
#define ll long long
#define M 4080
#define mmp make_pair
using namespace std;
const double inf = pow(2, 60);
int read() {
int nm = 0, f = 1;
char c = getchar();
for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
for(; isdigit(c); c = getchar()) nm = nm * 10 + c - '0';
return nm * f;
}
struct Note {
int x, y, f;
bool operator < (const Note &b) const {
return x == b.x ? y < b.y : x < b.x;
}
} note[M];
int n, m, L, R, lx[M], ly[M], rx[M], ry[M], bex, bey, edx, edy, tp;
vector<pair<int, double> > to[M];
double f[M], v, ans;
double dis(Note a, Note b) {
return sqrt(1.0 * (a.x - b.x) * (a.x - b.x) + 1.0 * (a.y - b.y) * (a.y - b.y));
}
int main() {
n = read();
for(int i = 1; i <= n; i++) lx[i] = read(), ly[i] = read(), rx[i] = read(), ry[i] = read();
bex = read(), bey = read(), edx = read(), edy = read();
if(bex == edx) {
ans = (bey > edy) ? bey - edy : edy - bey;
} else {
if(bex > edx) swap(bex, edx), swap(bey, edy);
note[++tp] = (Note) {
bex, bey, 1
};
note[++tp] = (Note) {
edx, edy, 2
};
for(int i = 1; i < n; i++) {
int maxx = max(ly[i], ly[i + 1]), minn = min(ry[i], ry[i + 1]);
note[++tp] = (Note) {
lx[i + 1], minn, 3
};
note[++tp] = (Note) {
lx[i + 1], maxx, 4
};
}
sort(note + 1, note + tp + 1);
for(int i = 1; i <= tp; i++) {
if(note[i].f == 1) L = i;
if(note[i].f == 2) R = i;
}
for(int i = L; i <= R; i++) {
double le = -inf, re = inf;
for(int j = i + 1; j <= R; j++) {
if(note[j].x == note[i].x) {
to[j].push_back(mmp(i, note[j].y - note[i].y));
continue;
}
double slp = 1.0 * (note[j].y - note[i].y) / (note[j].x - note[i].x);
if(slp >= le && slp <= re) to[j].push_back(mmp(i, dis(note[i], note[j])));
if(note[j].f == 4) le = max(le, slp);
else re = min(re, slp);
}
}
for(int i = L + 1; i <= R; i++) {
f[i] = inf;
for(int j = 0; j < to[i].size(); j++) {
// cout << to[i][j].second << "\n";
f[i] = min(f[i], f[to[i][j].first] + to[i][j].second);
}
}
ans = f[R];
}
cin >> v;
ans /= v;
printf("%.8lf\n", ans);
return 0;
}

[NOI2011]智能车比赛 (计算几何 DAG)的更多相关文章

  1. 2433: [Noi2011]智能车比赛 - BZOJ

    Description 新一届智能车大赛在JL大学开始啦!比赛赛道可以看作是由n个矩形区域拼接而成(如下图所示),每个矩形的边都平行于坐标轴,第i个矩形区域的左下角和右上角坐标分别为(xi,1,yi, ...

  2. Noi2011 : 智能车比赛

    假设S在T左边,那么只能往右或者上下走 f[i]表示S到i点的最短路 f[i]=min(f[j]+dis(i,j)(i能看到j)) 判断i能看到j就维护一个上凸壳和一个下凸壳 时间复杂度$O(n^2) ...

  3. [bzoj2433][Noi2011]智能车比赛

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2433 http://221.192.240.123:8586/JudgeOnline/ ...

  4. 【[NOI2011]智能车比赛】(建图+spfa+坑爹精度)

    过了这题我就想说一声艹,跟这个题死磕了将近6个小时,终于是把这个题死磕出来了.首先看到这个题的第一反应,和当初做过的一个房间最短路比较相似,然后考虑像那个题那样建边,然后跑最短路.(具体建边方法请参考 ...

  5. BZOJ 2433 智能车比赛(计算几何+最短路)

    题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=2433 题意:若干个矩形排成一排(同一个x之上最多有一个矩形),矩形i和i+1相邻.给定两 ...

  6. 【LOJ】#2443. 「NOI2011」智能车比赛

    题解 显然是个\(n^2\)的dp 我们要找每个点不穿过非赛道区域能到达哪些区域的交点 可以通过控制两条向量负责最靠下的上边界,和最靠上的下边界,检查当前点在不在这两条向量之间即可,对于每个点可以\( ...

  7. 智能车学习(十五)——K60野火2013版例程

    一.中断函数注册方法: 1.格式: 配置某个功能的中断 注册中断函数 开启中断 2.一个例子 pit_init_ms(PIT0,);//定时中断初始化 set_vector_handler(PIT0_ ...

  8. K60平台智能车开发工作随手记

    (图片仅为示例,并不一定固定为这种造型) 第十二届全国大学生智能汽车竞赛有一个分项是光电四轮车的竞速(任务A),Seven她们组采购到的配件使用了freescale Crotex-M4内核的CPU,T ...

  9. 【sky第二期--PID算法】--【智能车论坛】

    [sky第二期--PID算法] 想学PID的可以来[智能车论坛]这里有我发布的资料http://bbs.tekbots.eefocus.com/forum.php?mod=viewthread& ...

随机推荐

  1. python项目运行环境安装小结

    安装最新即可,实际的版本号可能不一样 安装过程较复杂,建议用一台单独的vm安装,能做成docker image最好 基础软件 nginx-1.10.0: sudo apt-get install ng ...

  2. 移动rem自适应

    /** * rem计算方式:设计图尺寸px / 100 = 实际rem 例: 100px = 1rem */!function (window) { /* 设计图文档宽度 */ var docWidt ...

  3. Android开发 ---SQLite数据库,lock文件,结果集游标,适配器,安全退出,给连接设置下划线,编辑器,投影,ContentValues存储,DbHelper,activity栈

    目录截图: 1.activity_main.xml 主界面效果: <?xml version="1.0" encoding="utf-8"?> &l ...

  4. tomcat的LifecycleException异常

    异常:start: org.apache.catalina.LifecycleException: tomcat版本:8 解决:将tomcat的版本换成tomcat6,问题解决了

  5. quora 的东西就是不一样

    Coding is just a part of process of problem solving, You should need to understand the underlying pr ...

  6. 剑指Offer 10. 矩形覆盖 (递归)

    题目描述 我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形.请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法? 题目地址 https://www.nowcoder.com/ ...

  7. U-Boot shell脚本语法

    /********************************************************************** * U-Boot shell脚本语法 * 说明: * 之 ...

  8. C++程序设计-面向对象

    1-1面向对象初探 变量也是Object Data: the properties  or status; is the core Operations: the functions对外能提供的服务, ...

  9. es6模块与 commonJS规范的区别

    https://www.cnblogs.com/weblinda/p/6740833.html

  10. C# Restful 启用 Session

    虽然很多人说不建议启用,但我就是想启用. [ServiceContract(SessionMode=SessionMode.Allowed)] public interface IBIService ...