{"problem":{"name":"C. Mice problem","description":{"content":"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 infini","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF793C"},"statements":[{"statement_type":"Markdown","content":"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.\n\nThe 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).\n\nIgor 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.\n\nIgor 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.\n\n## Input\n\nThe first line contains single integer _n_ (1 ≤ _n_ ≤ 100 000) — the number of computer mice on the desk.\n\nThe 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.\n\nThe next _n_ lines contain the information about mice.\n\nThe _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.\n\n## Output\n\nIn 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_.\n\nYour answer is considered correct if its absolute or relative error doesn't exceed 10 - 6.\n\nFormally, let your answer be _a_, and the jury's answer be _b_. Your answer is considered correct if .\n\n[samples]\n\n## Note\n\nHere is a picture of the first sample\n\nPoints A, B, C, D - start mice positions, segments are their paths.\n\n![image](https://espresso.codeforces.com/6a0b8b0786746f4d0bd24cde857f0bfb33d6638d.png)\n\nThen, at first time when all mice will be in rectangle it will be looks like this:\n\n![image](https://espresso.codeforces.com/c801dd4c22c893568d85350904f8ba3bf12e97e4.png)\n\nHere is a picture of the second sample\n\n![image](https://espresso.codeforces.com/0bd5e231bae43659410f4f2af1078e56c08c729c.png)\n\nPoints A, D, B will never enter rectangle.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"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.\n\nThe 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 $(x1, y1)$ and $(x2, y2)$.\n\nIgor 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 $(vix, viy)$, that means that the $x$ coordinate of the mouse increases by $vix$ units per second, while the $y$ coordinates increases by $viy$ 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.\n\nIgor 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.\n\nThe first line contains single integer $n$ ($1 ≤ n ≤ 100 000$) — the number of computer mice on the desk.\n\nThe second line contains four integers $x1$, $y1$, $x2$ and $y2$ ($0 ≤ x1 ≤ x2 ≤ 100 000$), ($0 ≤ y1 ≤ y2 ≤ 100 000$) — the coordinates of the opposite corners of the mousetrap.\n\nThe next $n$ lines contain the information about mice.\n\nThe $i$-th of these lines contains four integers $rix$, $riy$, $vix$ and $viy$, ($0 ≤ rix, riy ≤ 100 000$, $ - 100 000 ≤ vix, viy ≤ 100 000$), where $(rix, riy)$ is the initial position of the mouse, and $(vix, viy)$ is its speed.\n\nIn 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_.\n\nYour answer is considered correct if its absolute or relative error doesn't exceed $10 - 6$. \n\nFormally, let your answer be $a$, and the jury's answer be $b$. Your answer is considered correct if .\n\nHere is a picture of the first sample\n\nPoints A, B, C, D - start mice positions, segments are their paths.\n\nThen, at first time when all mice will be in rectangle it will be looks like this:\n\nHere is a picture of the second sample\n\nPoints A, D, B will never enter rectangle.\n\n## Input\n\nThe first line contains single integer $n$ ($1 ≤ n ≤ 100 000$) — the number of computer mice on the desk.The second line contains four integers $x1$, $y1$, $x2$ and $y2$ ($0 ≤ x1 ≤ x2 ≤ 100 000$), ($0 ≤ y1 ≤ y2 ≤ 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 $rix$, $riy$, $vix$ and $viy$, ($0 ≤ rix, riy ≤ 100 000$, $ - 100 000 ≤ vix, viy ≤ 100 000$), where $(rix, riy)$ is the initial position of the mouse, and $(vix, viy)$ is its speed.\n\n## Output\n\nIn 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 .\n\n[samples]\n\n## Note\n\nHere is a picture of the first samplePoints 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 samplePoints A, D, B will never enter rectangle.","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of mice.  \nLet $ R = [x_1, x_2] \\times [y_1, y_2] \\subset \\mathbb{R}^2 $ be the rectangular mousetrap, with $ x_1 \\le x_2 $, $ y_1 \\le y_2 $.  \nFor each mouse $ i \\in \\{1, \\dots, n\\} $:  \n- Initial position: $ \\mathbf{p}_i = (r_{ix}, r_{iy}) \\in \\mathbb{R}^2 $  \n- Velocity vector: $ \\mathbf{v}_i = (v_{ix}, v_{iy}) \\in \\mathbb{R}^2 $  \n- Position at time $ t \\ge 0 $: $ \\mathbf{p}_i(t) = (r_{ix} + t \\cdot v_{ix},\\ r_{iy} + t \\cdot v_{iy}) $\n\n**Constraints**  \n1. $ 1 \\le n \\le 100{,}000 $  \n2. $ 0 \\le x_1 \\le x_2 \\le 100{,}000 $, $ 0 \\le y_1 \\le y_2 \\le 100{,}000 $  \n3. $ 0 \\le r_{ix}, r_{iy} \\le 100{,}000 $  \n4. $ -100{,}000 \\le v_{ix}, v_{iy} \\le 100{,}000 $\n\n**Objective**  \nFind the minimal $ t \\ge 0 $ such that for all $ i \\in \\{1, \\dots, n\\} $:  \n$$\nx_1 < r_{ix} + t \\cdot v_{ix} < x_2 \\quad \\text{and} \\quad y_1 < r_{iy} + t \\cdot v_{iy} < y_2\n$$  \nIf no such $ t $ exists, output $ -1 $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF793C","tags":["geometry","implementation","math","sortings"],"sample_group":[["4\n7 7 9 8\n3 5 7 5\n7 5 2 4\n3 3 7 8\n6 6 3 2","0.57142857142857139685"],["4\n7 7 9 8\n0 3 -5 4\n5 0 5 4\n9 9 -1 -6\n10 5 -7 -10","\\-1"]],"created_at":"2026-03-03 11:00:39"}}