C. Chris and Road
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

And while Mishka is enjoying her trip...

Chris is a little brown bear. No one knows, where and when he met Mishka, but for a long time they are together (excluding her current trip). However, best friends are important too. John is Chris' best friend.

Once walking with his friend, John gave Chris the following problem:

At the infinite horizontal road of width w, bounded by linesy = 0 and y = w, there is a bus moving, presented as a convex polygon ofn vertices. The bus moves continuously with a constant speed ofv in a straight Ox line in direction of decreasingx coordinates, thus in time only x coordinates of its points are changing. Formally, after timet each of x coordinates of its points will be decreased byvt.

There is a pedestrian in the point (0, 0), who can move only by a vertical pedestrian crossing, presented as a segment connecting points(0, 0) and (0, w)with any speed not exceedingu. Thus the pedestrian can move only in a straight lineOy in any direction with any speed not exceedingu and not leaving the road borders. The pedestrian can instantly change his speed, thus, for example, he can stop instantly.

Please look at the sample note picture for better understanding.

We consider the pedestrian is hit by the bus, if at any moment the point he is located in liesstrictly inside the bus polygon (this means that if the point lies on the polygon vertex or on its edge, the pedestrian is not hit by the bus).

You are given the bus position at the moment 0. Please help Chris determine minimum amount of time the pedestrian needs to cross the road and reach the point(0, w) and not to be hit by the bus.

Input

The first line of the input contains four integers n,wv,u (3 ≤ n ≤ 10 000,1 ≤ w ≤ 109,1 ≤ v,  u ≤ 1000) — the number of the bus polygon vertices, road width, bus speed and pedestrian speed respectively.

The next n lines describes polygon vertices in counter-clockwise order.i-th of them contains pair of integers xi and yi ( - 109 ≤ xi ≤ 109,0 ≤ yi ≤ w) — coordinates ofi-th polygon point. It is guaranteed that the polygon is non-degenerate.

Output

Print the single real t — the time the pedestrian needs to croos the road and not to be hit by the bus. The answer is considered correct if its relative or absolute error doesn't exceed10 - 6.

Example
Input
5 5 1 2
1 2
3 1
4 3
3 4
1 4
Output
5.0000000000
Note

Following image describes initial position in the first sample case:

题目大意:

人从原点出发,可以以小于等于u的任意速度向上或向下运动,一个n边型的车以恒定的速度v向左运动(竟然有车长得这么奇葩),给出车各个点的初始坐标。求人在不被车撞的前提下最快到达对面的时间。

解题思路:

一共有两种情况。

第一种情况、人开始就一直以u的速度往前走,没有被车撞。那么时间最短就是w/u。

第二种情况,人要在车后面过去。那么为了时间最短人一定要安全的前提下尽量贴着车走才能时间最短。

我们可以将问题看成车不动,人先水平移动一段距离,再沿着斜率为u/v的直线运动。那么就变成了平移直线使其与车相切。由于车的每条边都是直线,那么切点一定在顶点上。我们只要枚举全部顶点,一个点和一个斜率就可以确定一条直线。我们只要找到最左边和最右边一条直线则这两条直线与车一定是相切的。这时切线与x轴交点如果在原点左边,那么就是第一种情况。否则是第二种情况。在我们新建的模型下时间就非常好求。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
int n,w,v,u;
int main()
{
scanf("%d%d%d%d",&n,&w,&v,&u);
double k=u*1.0/v,l=(double)(<<)-,r=;
int i;
//cout<<l<<endl;
for (i=;i<=n;i++)
{
int x,y;
scanf("%d%d",&x,&y);
l=min(l,x-y/k);
r=max(r,x-y/k);
}
printf("%.10lf\n",l>?w*1.0/u:r/v+w*1.0/u);
return ;
}

Codeforces 703C(计算几何)的更多相关文章

  1. CodeForces 703C Chris and Road

    数学,递推. 不知道有没有更加神奇的做法,我是这样想的: 首先,如果多边形完全在$y$轴左侧,那么答案为$\frac{w}{u}$. 剩下的情况就要先判断是否能在车开过之前跑过去,如果跑不过去,要在车 ...

  2. Codeforces Gym100543B 计算几何 凸包 线段树 二分/三分 卡常

    原文链接https://www.cnblogs.com/zhouzhendong/p/CF-Gym100543B.html 题目传送门 - CF-Gym100543B 题意 给定一个折线图,对于每一条 ...

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

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

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

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

  5. Codeforces Round #335 (Div. 1) C. Freelancer's Dreams 计算几何

    C. Freelancer's Dreams Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contes ...

  6. Codeforces 749B:Parallelogram is Back(计算几何)

    http://codeforces.com/problemset/problem/749/B 题意:已知平行四边形三个顶点,求另外一个顶点可能的位置. 思路:用向量来做. #include <c ...

  7. Codeforces Round #339 (Div. 1) A. Peter and Snow Blower 计算几何

    A. Peter and Snow Blower 题目连接: http://www.codeforces.com/contest/613/problem/A Description Peter got ...

  8. Codeforces Round #524 (Div. 2) C. Masha and two friends(思维+计算几何?)

    传送门 https://www.cnblogs.com/violet-acmer/p/10146350.html 题意: 有一块 n*m 的棋盘,初始,黑白块相间排列,且左下角为白块. 给出两个区间[ ...

  9. Codeforces 528E Triangles 3000 - 计算几何

    题目传送门 传送点I 传送点II 传送点III 题目大意 给定$n$的平面上的直线,保证没有三条直线共点,两条直线平行.问随机选出3条直线交成的三角形面积的期望. 显然$S=\frac{1}{2}ah ...

随机推荐

  1. 毕业设计:HomeFragment(二)

    一.长按item时的响应 在长按item时,我希望能让CheckBox显示出来,并且呼出全选.反选.取消菜单,以及下载.删除.移动.复制操作菜单. 我在具体实现的时候发现处理item布局是一个很大的问 ...

  2. 如何使用xftp工具在Windows与Linux之间传输文件

    如何使用xftp工具在Windows与Linux之间传输文件 整理者:vashon 声明:感谢开源社区 xftp工具是一款SFTP,FTP文件传输软件,可在Windows pc与Unix/Linux之 ...

  3. Unity Shader-热空气扭曲效果

    GrabPass GrabPass是Unity为我们提供的一个很方便的功能,可以直接将当前屏幕内容渲染到一张贴图上,我们可以直接在shader中使用这张贴图而不用自己去实现渲染到贴图这样的一个过程,大 ...

  4. Django请求,响应,ajax以及CSRF问题

    二.request对象常用属性: Attribute Description path 请求页面的全路径,不包括域名端口参数.例如: /users/index method 一个全大写的字符串,表示请 ...

  5. @click.native 会触发原生 click事件 vue

    @click.native 会触发原生 click事件 vue

  6. 在移动端实现1px的边框

    由于分辨率 DPI 的差异,高清手机屏上的 1px 实际上是由 2×2 个像素点来渲染,有的屏幕甚至用到了 3×3 个像素点 所以 border: 1px 在移动端会渲染为 2px 的边框 与设计图产 ...

  7. vgg16原始的protocol

    # Enter your network definition here. # Use Shift+Enter to update the visualization.name: "VGG_ ...

  8. Java以组的数量将字符串分组

    package org.jimmy.autosearch2019.test; import java.util.ArrayList; public class Test20190327 { publi ...

  9. linux查看内存和释放内存

    linux: 查看内存:free -m 释放内存:echo 1 > /proc/sys/vm/drop_caches

  10. modify django app models.py adn settings.py

    from django.db import models from django.contrib import admin # from personal import models class Us ...