数学,递推。

不知道有没有更加神奇的做法,我是这样想的:

首先,如果多边形完全在$y$轴左侧,那么答案为$\frac{w}{u}$。

剩下的情况就要先判断是否能在车开过之前跑过去,如果跑不过去,要在车慢慢开过$y$轴的时候,一起慢慢跑上去。

那么先来判断是否能在车开过之前跑过去:

如上图所示,如果要在车来车前跑过去,那么等价于要求:对于凸包左侧蓝色链上的每一个点$L[i]$,满足$\frac{{L[i].y}}{u} ≤ \frac{{L[i].x}}{v}$,即人要比点先到。如果有一个点不满足,那么就人就无法在车来前跑过去。如果可以的话,答案为$\frac{w}{u}$。

剩下的情况就是凸包右侧黄色链开过$y$轴时,人同时走上去。这种情况的答案,递推一下就能算出来了,如果人走到$(0,R[i].y)$所花的时间为$ans$,那么人走到$(0,R[i+1].y)$的时间$ans$更新为$\max (ans + \frac{{\left( {R\left[ {i + 1} \right].y-R\left[ i \right].y } \right)}}{u},\frac{{R[i].x}}{v})$,想一想也能想明白吧~

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-;
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
} const int INF=;
const int maxn=;
int n,w,v,u,len1,len2;
struct X { int x,y; }p[maxn],L[maxn],R[maxn]; int main()
{
scanf("%d%d%d%d",&n,&w,&v,&u);
for(int i=;i<=n;i++) scanf("%d%d",&p[i].x,&p[i].y); int ymin=INF,ymax=-INF,f,p1,p2; bool flag;
for(int i=;i<=n;i++) ymin=min(ymin,p[i].y), ymax=max(ymax,p[i].y);
f=INF; for(int i=;i<=n;i++) if(p[i].y==ymin&&p[i].x<f) f=p[i].x,p1=i;
f=INF; for(int i=;i<=n;i++) if(p[i].y==ymax&&p[i].x<f) f=p[i].x,p2=i; flag=; for(int i=p1;i>=;i--) { L[len1++]=p[i]; if(i==p2) { flag=; break; } }
if(flag==) for(int i=n;i>=p2;i--) L[len1++]=p[i]; f=-INF; for(int i=;i<=n;i++) if(p[i].y==ymin&&p[i].x>f) f=p[i].x,p2=i;
f=-INF; for(int i=;i<=n;i++) if(p[i].y==ymax&&p[i].x>f) f=p[i].x,p1=i; flag=; for(int i=p1;i>=;i--) { R[len2++]=p[i]; if(i==p2) { flag=; break; } }
if(flag==) for(int i=n;i>=p2;i--) R[len2++]=p[i]; for(int i=;i<len2/;i++) swap(R[i],R[len2-i-]);
bool fail=; for(int i=;i<len1;i++) if((LL)L[i].y*(LL)v>(LL)L[i].x*(LL)u) { fail=; break; } int xmax=-INF; for(int i=;i<=n;i++) xmax=max(xmax,p[i].x);
if(xmax<=) fail=;
if(fail==) printf("%.6lf\n",1.0*w/u);
else
{
double ans=; int pre=;
for(int i=;i<len2;i++)
{
ans=ans+1.0*(R[i].y-pre)/u; pre=R[i].y;
ans=max(ans,1.0*R[i].x/v);
}
ans=ans+1.0*(w-pre)/u;
printf("%.6lf\n",ans);
}
return ;
}

CodeForces 703C Chris and Road的更多相关文章

  1. CodeForces 703C Chris and Road (简单几何)

    题意:有一个n边形的汽车向以速度v向x轴负方向移动,给出零时时其n个点的坐标.并且有一个人在(0,0)点,可以以最大速度u通过w宽的马路,到达(0,w)点.现在要求人不能碰到汽车,人可以自己调节速度. ...

  2. Codeforces Round #365 (Div. 2) C - Chris and Road 二分找切点

    // Codeforces Round #365 (Div. 2) // C - Chris and Road 二分找切点 // 题意:给你一个凸边行,凸边行有个初始的速度往左走,人有最大速度,可以停 ...

  3. Codeforces Round #365 (Div. 2) Chris and Road

    Chris and Road 题意: 给一个n个顶点的多边形的车,有速度v,人从0走到对面的w,人速度u,问人最快到w的时间是多少,车如果挡到人,人就不能走. 题解: 这题当时以为计算几何,所以就没做 ...

  4. cf703C Chris and Road

    C. Chris and Road time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  5. 暑假练习赛 003 B Chris and Road

    B - Chris and Road Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144K ...

  6. Codeforces 703C(计算几何)

    C. Chris and Road time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  7. 【23.15%】【codeforces 703C】Chris and Road

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  8. Codeforces Educational Codeforces Round 15 D. Road to Post Office

    D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...

  9. 【26.83%】【Codeforces Round #380C】Road to Cinema

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

随机推荐

  1. orchard相关网址

    1.官网文档  http://docs.orchardproject.net/ 2.github  https://github.com/OrchardCMS/Orchard 3.stackoverf ...

  2. List中函数用法 First,FirstOrDefault,Single,SingleOrDefault的区别

    操作符 如果源序列是空的 源序列只包含一个元素 源序列包含多个元素 First 抛异常 返回该元素 返回第一个元素 FirstOrDefault 返回default(TSource) 返回该元素 返回 ...

  3. ELK采集之nginx 之高德地图出城市IP分布图

    1.采用拓扑: 角色扮演: Agent:采用logstash,IP:192.168.10.7 Redis队列: IP:192.168.10.100 Indexer:logstash,IP:192.16 ...

  4. git 查看某个文件的历史修改版本

    [git status 查看修改的文件路径] git log --follow -p routes/admin/contract_operation.js

  5. 关于在框架中使用curl的思考,以及,curl其实很好用

    初步猜想: 在接触到框架文档的第一阶段时,会觉得控制器调用模型就是一件很简单的事,tp中用D方法或者M方法来实例化模型,laravel中用命名空间来加载模型,CI中用$this->load-&g ...

  6. C#:继承多态的方法实现数的简单加减乘除运算

       // 定义一个抽象的父类     abstract class Figure     {         //声明抽象方法:         //父类中的所有家里人可以用的方法必须都应用到子类中 ...

  7. 导入spring源码到eclipse

    1.1安装Gradle 可以从http://www.gradle.org/downloads页面下载Gradle.下载后将文件解压到指定目录,我放在D:\软件\gradle-3.3,然后设置环境变量. ...

  8. HDU 5895 Mathematician QSC

    矩阵快速幂,欧拉定理. $g(n)$递推式:$g(n)=5g(n-1)+5g(n-2)-g(n-3)$,可以构造矩阵快速求递$n$项,指数很大,可以利用欧拉定理降幂. #pragma comment( ...

  9. Payload Inject And Fake

    常见捆绑注入payload手法 Payload捆绑注入 注入exe型+编码: msfvenom -a <arch> --plateform <platform> -p < ...

  10. TCP滑动窗口控制流量的原理

    TCP的滑动窗口机制       TCP这个协议是网络中使用的比较广泛,他是一个面向连接的可靠的传输协议.既然是一个可靠的传输协议就需要对数据进行确认.TCP协议里窗口机制有2种:一种是固定的窗口大小 ...