CF793C.Mice problem

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

分析员伊戈尔在工作时睡着了,做了一个奇怪的梦。在梦中,他的办公桌上挤满了电脑鼠标(此处指啮齿类动物),于是他买了一个捕鼠器来捕捉它们。

办公桌可视为一个无限平面,捕鼠器是一个边与坐标轴平行的矩形,其一对对顶点位于点 (x1,y1)(x_1, y_1) 和 (x2,y2)(x_2, y_2)。

伊戈尔希望捕获所有老鼠。他分析了老鼠的行为,发现每只老鼠均沿一条直线以恒定速度运动;第 ii 只老鼠的速度为 (vix,viy)(v_{ix}, v_{iy}),即其 xx 坐标每秒增加 vixv_{ix} 个单位,yy 坐标每秒增加 viyv_{iy} 个单位。捕鼠器初始处于开启状态,因此老鼠可在桌面上自由移动。伊戈尔可在任意时刻关闭捕鼠器,从而捕获所有严格位于捕鼠器内部的老鼠。

伊戈尔工作繁忙,即便在梦中也十分忙碌,因此他请你编写一个程序:给定捕鼠器的坐标、老鼠的初始位置及其速度,求出他能够捕获所有老鼠的最早时刻。请注意:伊戈尔仅能关闭捕鼠器一次。

输入格式

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.

第一行包含一个整数 nn(1≤n≤100 0001 \leq n \leq 100\,000)—— 桌面上计算机鼠标(老鼠)的数量。

第二行包含四个整数 x1x_1、y1y_1、x2x_2 和 y2y_2(0≤x1≤x2≤100 0000 \leq x_1 \leq x_2 \leq 100\,000,0≤y1≤y2≤100 0000 \leq y_1 \leq y_2 \leq 100\,000)—— 捕鼠器(矩形区域)两个对角顶点的坐标。

接下来的 nn 行描述了每只老鼠的信息。

其中第 ii 行包含四个整数 rixr_{ix}、riyr_{iy}、vixv_{ix} 和 viyv_{iy}(0≤rix, riy≤100 0000 \leq r_{ix},\,r_{iy} \leq 100\,000,−100 000≤vix, viy≤100 000-100\,000 \leq v_{ix},\,v_{iy} \leq 100\,000),其中 (rix, riy)(r_{ix},\,r_{iy}) 是该老鼠的初始位置,(vix, viy)(v_{ix},\,v_{iy}) 是其速度。

输出格式

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 .

在唯一的一行中,输出最小的非负数 tt,使得 Igor 从开始经过 tt 秒后关闭捕鼠器时,所有老鼠都严格位于捕鼠器内部。若不存在这样的 tt,则输出 −1-1。

当你的答案的绝对误差或相对误差不超过 10−610^{-6} 时,即视为正确。

形式化地,设你的答案为 aa,评测组的答案为 bb。当满足 时,你的答案即视为正确。

输入输出样例

  • 输入#1

    4
    7 7 9 8
    3 5 7 5
    7 5 2 4
    3 3 7 8
    6 6 3 2

    输出#1

    0.57142857142857139685
  • 输入#2

    4
    7 7 9 8
    0 3 -5 4
    5 0 5 4
    9 9 -1 -6
    10 5 -7 -10

    输出#2

    -1

说明/提示

Here is a picture of the first sample

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

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

Here is a picture of the second sample

Points A, D, B will never enter rectangle.

以下是第一个样例的示意图:

点 A、B、C、D 表示老鼠的初始位置,线段表示它们的运动路径。

随后,所有老鼠首次同时位于矩形内部时的情形如下图所示:

以下是第二个样例的示意图:

点 A、D、B 永远不会进入该矩形。

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

首页