CF703C.Chris and Road
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
而米什卡正在享受她的旅行……
克里斯是一只小棕熊。没人知道他是在何时何地结识米什卡的,但很长一段时间以来,他们一直在一起(除她此次旅行外)。然而,最好的朋友也同样重要——约翰就是克里斯最好的朋友。
一次,当克里斯与朋友约翰同行时,约翰给了克里斯如下问题:
在一条无限长的水平道路(宽度为 w)上,该道路由直线 y=0 和 y=w 所围成,有一辆公交车正沿道路行驶;这辆公交车被建模为一个具有 n 个顶点的凸多边形。公交车以恒定速度 v 沿 Ox 轴方向持续匀速运动,且运动方向为 x 坐标减小的方向(即向左平移)。因此,在任意时刻,其所有点的 x 坐标均随时间线性变化。形式化地说:经过时间 t 后,其各顶点的 x 坐标均减少 vt。
在点 (0,0) 处有一位行人,他只能沿一条垂直的人行横道移动;该人行横道是一条连接点 (0,0) 与 (0,w) 的线段,其最大移动速度为 u。因此,该行人仅能在 Oy 轴方向(即竖直方向)上以任意方向、任意不超过 u 的速度移动,且不可越出道路边界(即 y∈[0,w])。行人可瞬间改变其速度(例如,可立即停止)。
请参阅样例说明中的示意图以获得更直观的理解。
我们认为:若在某一时刻,行人所处的位置严格位于公交车多边形内部,则该行人被公交车撞到(即:若该点恰好落在多边形的顶点或边上,则不视为被撞)。
已知公交车在时刻 0 的位置,请帮助克里斯计算行人安全穿越道路、抵达点 (0,w) 所需的最短时间(即不被公交车撞到的前提下,从 (0,0) 到达 (0,w) 的最小耗时)。
输入格式
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 x__i and y__i ( - 109 ≤ x__i ≤ 109, 0 ≤ y__i ≤ w) — coordinates of i-th polygon point. It is guaranteed that the polygon is non-degenerate.
输入的第一行包含四个整数 n、w、v、u(3 ≤ n ≤ 10000,1 ≤ w ≤ 109,1 ≤ v,u ≤ 1000),分别表示公交车多边形的顶点数、道路宽度、公交车速度和行人速度。
接下来的 n 行按逆时针顺序描述多边形的各个顶点。第 i 行包含两个整数 xi 和 yi(−109 ≤ xi ≤ 109,0 ≤ yi ≤ w),表示第 i 个顶点的坐标。保证该多边形是非退化的。
输出格式
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.
输出唯一的实数 t —— 行人穿过马路且不被公交车撞到所需的时间。若答案的相对误差或绝对误差不超过 10−6,则视为正确。
输入输出样例
输入#1
5 5 1 2 1 2 3 1 4 3 3 4 1 4
输出#1
5.0000000000
说明/提示
Following image describes initial position in the first sample case:

下图描述了第一个样例的初始位置:

输入解题思路,AI测评打分。不知道怎么写?