Tinkoff Challenge - Elimination Round
C
Mice problem
Codeforces
2300
原题
← BD →
翻译中…

Igor the analyst fell asleep on the work and had a strange dream. In the dream his desk was crowded with computer mice, so he bought a mousetrap to catch them.

翻译中…

The desk can be considered as an infinite plane, then the mousetrap is a rectangle which sides are parallel to the axes, and which opposite sides are located in points $(*x*_{1}, *y*_{1})$ and $(*x*_{2}, *y*_{2})$.

翻译中…

Igor wants to catch all mice. Igor has analysed their behavior and discovered that each mouse is moving along a straight line with constant speed, the speed of the $*i*$-th mouse is equal to $(*v*_{*i*}^{*x*}, *v*_{*i*}^{*y*})$, that means that the $*x*$ coordinate of the mouse increases by $*v*_{*i*}^{*x*}$ units per second, while the $*y*$ coordinates increases by $*v*_{*i*}^{*y*}$ units. The mousetrap is open initially so that the mice are able to move freely on the desk. Igor can close the mousetrap at any moment catching all the mice that are strictly inside the mousetrap.

翻译中…

Igor works a lot, so he is busy in the dream as well, and he asks you to write a program that by given mousetrap's coordinates, the initial coordinates of the mice and their speeds determines the earliest time moment in which he is able to catch all the mice. Please note that Igor can close the mousetrap only once.

翻译中…

Input

翻译中…

The first line contains single integer $*n*$ ($1 ≤ *n* ≤ 100 000$) — the number of computer mice on the desk.

翻译中…

The second line contains four integers $*x*_{1}$, $*y*_{1}$, $*x*_{2}$ and $*y*_{2}$ ($0 ≤ *x*_{1} ≤ *x*_{2} ≤ 100 000$), ($0 ≤ *y*_{1} ≤ *y*_{2} ≤ 100 000$) — the coordinates of the opposite corners of the mousetrap.

翻译中…

The next $*n*$ lines contain the information about mice.

翻译中…

The $*i*$-th of these lines contains four integers $*r*_{*i*}^{*x*}$, $*r*_{*i*}^{*y*}$, $*v*_{*i*}^{*x*}$ and $*v*_{*i*}^{*y*}$, ($0 ≤ *r*_{*i*}^{*x*}, *r*_{*i*}^{*y*} ≤ 100 000$, $- 100 000 ≤ *v*_{*i*}^{*x*}, *v*_{*i*}^{*y*} ≤ 100 000$), where $(*r*_{*i*}^{*x*}, *r*_{*i*}^{*y*})$ is the initial position of the mouse, and $(*v*_{*i*}^{*x*}, *v*_{*i*}^{*y*})$ is its speed.

翻译中…

Output

翻译中…

In the only line print minimum possible non-negative number $*t*$ such that if Igor closes the mousetrap at $*t*$ seconds from the beginning, then all the mice are strictly inside the mousetrap. If there is no such $*t*$, print -1.

翻译中…

Your answer is considered correct if its absolute or relative error doesn't exceed $10^{ - 6}$.

翻译中…

Formally, let your answer be $*a*$, and the jury's answer be $*b*$. Your answer is considered correct if image.

翻译中…

Note

翻译中…

Here is a picture of the first sample

翻译中…

Points A, B, C, D - start mice positions, segments are their paths.

翻译中…

image

翻译中…

Then, at first time when all mice will be in rectangle it will be looks like this:

翻译中…

image

翻译中…

Here is a picture of the second sample

翻译中…

image

翻译中…

Points A, D, B will never enter rectangle.

翻译中…

样例

Input #1
4
7 7 9 8
3 5 7 5
7 5 2 4
3 3 7 8
6 6 3 2
Output #1
0.57142857142857139685
InputCopy OutputCopy
Input #2
4
7 7 9 8
0 3 -5 4
5 0 5 4
9 9 -1 -6
10 5 -7 -10
Output #2
-1
InputCopy OutputCopy
题目信息
题号
793C
时间限制
2 s
内存限制
256 MB
标签
计算几何
模拟
数学
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。