暑假练习赛 003 B Chris and Road
Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
uDebugDescription
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
5 5 1 2
1 2
3 1
4 3
3 4
1 4
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 = ; 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 = , ok2 = ;
double t = ;
for(int i = ; i < m_v.size(); i++)
{
if (m_v[i].x / v > m_v[i].y / u)
ok1 = ;
if (m_v[i].x / v < m_v[i].y / u)
ok2 = ;
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 ;
}
暑假练习赛 003 B Chris and Road的更多相关文章
- 暑假练习赛 003 F Mishka and trip
F - Mishka and trip Sample Output Hint In the first sample test: In Peter's first test, there's on ...
- 暑假练习赛 003 A Spider Man
A - Spider Man Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144KB ...
- Codeforces Round #365 (Div. 2) Chris and Road
Chris and Road 题意: 给一个n个顶点的多边形的车,有速度v,人从0走到对面的w,人速度u,问人最快到w的时间是多少,车如果挡到人,人就不能走. 题解: 这题当时以为计算几何,所以就没做 ...
- Codeforces Round #365 (Div. 2) C - Chris and Road 二分找切点
// Codeforces Round #365 (Div. 2) // C - Chris and Road 二分找切点 // 题意:给你一个凸边行,凸边行有个初始的速度往左走,人有最大速度,可以停 ...
- cf703C Chris and Road
C. Chris and Road time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- 【23.15%】【codeforces 703C】Chris and Road
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- CodeForces 703C Chris and Road
数学,递推. 不知道有没有更加神奇的做法,我是这样想的: 首先,如果多边形完全在$y$轴左侧,那么答案为$\frac{w}{u}$. 剩下的情况就要先判断是否能在车开过之前跑过去,如果跑不过去,要在车 ...
- 暑假练习赛 007 E - Pairs
E - Pairs Description standard input/outputStatements In the secret book of ACM, it’s said: “Glory f ...
- 暑假练习赛 007 C - OCR
C - OCR Description standard input/outputStatements Optical Character Recognition (OCR) is one of th ...
随机推荐
- DialogFragment的应用
一.DialogFragment简单介绍: 1.基本概念 DialogFrament 指一个与fragment建立了关联的Dialog, 随fragment生, 随fragment死, 即Dialog ...
- 笨鸟先飞之ASP.NET MVC系列之过滤器(01过滤器简介)
过滤器 什么是过滤器? 过滤器(Filter) 主要的作用大致可以理解为把我们的附加逻辑注入到MVC框架的请求处理. 在ASP.NET MVC的请求处理中一种有19个管道事件分别是 BeginRequ ...
- Deep learning:一(基础知识_1)
本文纯转载: 主要是想系统的跟tornadomeet的顺序走一遍deeplearning; 前言: 最近打算稍微系统的学习下deep learing的一些理论知识,打算采用Andrew Ng的网页教程 ...
- localStorage和sessionStorage总结以及区别
(1)兼容的手机和浏览器: (2)使用 .setItem( key, value)存键值数据 sessionStorage.setItem("key","value&qu ...
- 理解js中的运算符优先级
前言 我是有过这样的经历,获取年月日时写出这样的代码: new Date().getFullYear() 此时的我是心虚的,因为我不知道是先执行.运算还是new运算,于是赶紧贴到控制台里,哎呦
- ch6-条件渲染(v-if v-else v-else-if key管理可复用元素 v-show )
1 v-if 1.1 简单使用 <h1 class="h1" v-if="ok">yes</h1> <script> var ...
- 学习的Python教程中的一些问题
2017开始学习Python,在网上找了很多教程,最后看到了Vamei的教程,感觉很简单易懂,但是过程中难免有不太容易理解的问题,做一些随笔,加深记忆亦可让以后学习的同学少走一些弯路. 1 Pytho ...
- 干了这杯Java之ArrayList
List存储一个有序元素合集 List接口的实现类有: ArrayList,LinkedList,Vector,Stack ArrayList一个数组型的List 默认容量为10 private st ...
- c# datetime与 timeStamp(unix时间戳) 互相转换
/// <summary> /// Unix时间戳转为C#格式时间 /// </summary> /// <param name="timeStamp" ...
- 提取多层嵌套Json数据
在.net 2.0中提取这样的json {"name":"lily","age":23,"addr":{"ci ...