暑假练习赛 003 B Chris and Road

B - Chris and Road

Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Submit Status Practice _ uDebug

Description

Input

Output

Sample Input

Sample Output

Hint

Description

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 lines y = 0 and y = w, there is a bus moving, presented as a convex polygon of n vertices. The bus moves continuously with a constant speed of v in a straight Ox line in direction of decreasing x coordinates, thus in time only x coordinates of its points are changing. Formally, after time t each of x coordinates of its points will be decreased by vt.

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 exceeding u. Thus the pedestrian can move only in a straight line Oy in any direction with any speed not exceeding u 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 lies strictly 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, w, v, 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 of i-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 exceed 10 - 6.

Sample Input

Input

5 5 1 21 23 14 33 41 4

Output

5.0000000000

Sample Output

Hint

Following image describes initial position in the first sample case:

/*
赛后除了F题才想这个B题的,被A题坑死了
先判断一下是否能在车来之前就过去,不能的话就按着最右边的点走
第二种情况很简单,只需要先按照y坐标排序,按照时间的顺序走x就行了
*/
# include <iostream>
# include <stdio.h>
# include <vector>
# include <algorithm>
# include <cstdio>
using namespace std;
struct Point
{
    double x;
    double y;
};
bool cmp(Point a, Point b)
{
    if(a.y != b.y)
        return a.y < b.y;
    return a.x < b.x;
}
int main()
{
    double n, w, v, u;
    while(scanf("%lf%lf%lf%lf",&n,&w,&v,&u)!=EOF)
    {
        vector <Point> m_v;
        for(int i = 0; i < n; i++)
        {
            Point p;
            scanf("%lf%lf",&p.x,&p.y);
            m_v.push_back(p);
        }
        sort(m_v.begin(), m_v.end(), cmp);
        bool ok1 = 1, ok2 = 1;
        double t = 0;
        for(int i = 0; i < m_v.size(); i++)
        {
            if (m_v[i].x / v > m_v[i].y / u)
                ok1 = 0;
            if (m_v[i].x / v < m_v[i].y / u)
                ok2 = 0;
            t = max(t, m_v[i].x / v + (w - m_v[i].y) / u);
        }
        if(ok1 || ok2)
            printf("%.10lf\n", w / u);
        else
            printf("%.10lf\n", t);
    }
    return 0;
}
时间: 2024-11-04 21:13:54

暑假练习赛 003 B Chris and Road的相关文章

暑假练习赛 003 F Mishka and trip

F - Mishka and trip Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Description Input Output Sample Input Sample Output Hint Description Peter Parker wants to play a g

暑假练习赛 003 A Spider Man

A - Spider Man Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Description Input Output Sample Input Sample Output Hint Description Peter Parker wants to play a game w

Chris and Road

E - Chris and Road CodeForces - 703C 题意:查询区间中出现偶数次的数的异或和 树状数组 若是求奇数次的数的异或和,很好求区间[l,r]的异或和,即前r项异或和与前l-1项异或和异或即可 但这要求偶数次的,想办法把偶数的转化成奇数的,即区间中出现奇数次的异或和与不同数的异或和 异或 即可 出现的奇数次的异或和写前缀数组解决,不同数的用树状数组优化,用一个map映射my[x]表示x的上一步的位置 代码如下: #include <iostream> #includ

CodeForces 703C Chris and Road

数学,递推. 不知道有没有更加神奇的做法,我是这样想的: 首先,如果多边形完全在$y$轴左侧,那么答案为$\frac{w}{u}$. 剩下的情况就要先判断是否能在车开过之前跑过去,如果跑不过去,要在车慢慢开过$y$轴的时候,一起慢慢跑上去. 那么先来判断是否能在车开过之前跑过去: 如上图所示,如果要在车来车前跑过去,那么等价于要求:对于凸包左侧蓝色链上的每一个点$L[i]$,满足$\frac{{L[i].y}}{u} ≤ \frac{{L[i].x}}{v}$,即人要比点先到.如果有一个点不满足

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

题意:有一个n边形的汽车向以速度v向x轴负方向移动,给出零时时其n个点的坐标.并且有一个人在(0,0)点,可以以最大速度u通过w宽的马路,到达(0,w)点.现在要求人不能碰到汽车,人可以自己调节速度.问人到达马路对面的最小时间是多少? 析:这个题是一个简单的分类讨论,很明显只有两种情况,第一种,直接到达w,不会被车撞到,答案就是w/u, 第二种是切着车过去,或者是等车过去再过去,只要枚举车的每个顶点,找到最后通过y轴的点就好,或者根本不会与车相切. 代码如下: #pragma comment(l

暑假练习赛 007 E - Pairs

E - Pairs Description standard input/outputStatements In the secret book of ACM, it’s said: “Glory for those who write short ICPC problems. May they live long, and never get Wrong Answers” . Everyone likes problems with short statements. Right? Let’s

暑假练习赛 007 B - Weird Cryptography

Weird Cryptography Description standard input/outputStatements Khaled was sitting in the garden under an apple tree, suddenly! , well... you should guess what happened, an apple fell on his head! , so he came up with a new Cryptography method!! The m

暑假练习赛 007 C - OCR

C - OCR Description standard input/outputStatements Optical Character Recognition (OCR) is one of the most famous fields of Artificial Intelligence. The main purpose of OCR is to recognize printed text (or handwriting) and convert it to the machine e

暑假练习赛 004 E Joint Stacks

Joint StacksCrawling in process... Crawling failed Time Limit:4000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 5818 uDebug Description Input Output Sample Input Sample Output Hint Description A stack is a d