Tinkoff Challenge

C. Mice problem
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 (x1, y1) and (x2, y2).

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 (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.

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 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 rixriyvix 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.

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 .

Examples
input
4
7 7 9 8
3 5 7 5
7 5 2 4
3 3 7 8
6 6 3 2
output
0.57142857142857139685
input
4
7 7 9 8
0 3 -5 4
5 0 5 4
9 9 -1 -6
10 5 -7 -10
output
-1
Note

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.

题目大意:给出坐标系中的一个矩形和一些点和他们的速度向量,求一个最小的时刻t使得这些点都严格在矩形内

这个严格要害死人哦

看上去只要枚举四条边求一下相交时间取个交集就好,然而特殊情况特别多

首先考虑一些和矩形相交在角上的坑爹情况,然后还有什么速度是0,在边上运动,最后还有答案区间是个(0.5,0.5)这种情况

一个很好的办法是求出相交时间后向正和向负各松弛eps,如果有一边严格在矩形内部就认为这个解合法

最后还要再判一下r-l是不是大于eps

wa了12次

  1 //:.:,:,:,:,:,:,:,:::,:,:,:::,:,:,,,,.. ....:,,.......,.rp .,,,,,..gBQ5v::G.,,:,:,:,:,:,:,:.
  2 //: .. ... ....... ........... .     .:;r77sJL77r7;;,.  :Ur        1sZDX1Bg  ... ... ... .. 
  3 //:.:,,,:,:,:,,,:,:,:,:,:,:,,,,...;vss5HH55L7rLLcri7wr;:,7Mw .rUK7:  O; ra:.,,,,:,:,,,,,:,:.
  4 //,.,:,,,,,:,:,:,:,:,:,:,,,,,,..;JsL72J, .   iH;. ., :;::,:BU..7s5SHKB7.   ..,,,,,,,,,,:,:,.
  5 //: :,,,,,,,,,,,,,:,,,,,,,,,, ,s2vcv5L      LOX7:  .  ;i::  sL.   .,Bv;Z6S7:,.,,,.,...,,,,:.
  6 //,.,,,,,,,:,,,,,,,:,,,,,,,, ;H2Lr7U7      aGLiwr.     7. :   .:QBBBMw, .7Jss:.. ..:cL,,,:,.
  7 //: :,,,,,,,,,:,,,,,:,,,,,, ;ZXL::Jv      wgLrr26,     ,;  ,   .BQRBpRg2,    .,:iJ5r2r.,,,:.
  8 //,.,,,:,:,,,:,,,,,,,,,,,, :ZK7,:LL.     ;gJr7L267      :   .:   7BM7SZO. :7s1Hg:7:  ..,,,,.
  9 //: :,,,,,,,,,,,,,,,,,,,,.,6H;,:rJ;     .DarrLv,KJ      .    ,    LLL,G6LX5c;,,:. ..,,,,,,:.
 10 //,.,:,,,,,,,,,,,,,,,,,,.,p2:,::r7. .   2Errsc..UX       .   7:.,.BM;:7r:.   ....,,,,,,,,,,.
 11 //:.:,,,,,,,,,,,,,,,,,,..c7.,:,:H:,:,  ,Rsrwv,,.Sp       r   :7;. :BvXU ...   ....,.,,,.,,:.
 12 //,.,,,,,,,:,,,,,,.,...;;:.:,..DX.:r.  SKca7,:.;6g   ..  H,  ,;;   ;POsaKE6P5J7;::.......,,.
 13 //: ,,,,,,,,,,,.,...,iv:,,:,,;EQ;.;;  ,gXKr.:.;J6E.  :.  U7. .:r..  B7  ..,:;rrZPcXpscvr;.:.
 14 //,.,:,,,,,:,,...::77r,,:;;cwEgg.,:r  wOH:.;:7JLwR.  r  ,1c: ::J.,  ;..,...... ,. :7.;P7:,,.
 15 //: ,,:,,,,,::r7s1Ss7r7ccLUHUXMc ,;;  RZ:.r;;s5:JR. ,r  77s:,LrJ,,  ::,.,,,.,,,.,.. ... .,:.
 16 //,.,,,,,:,,.,.,,:::;c7saXSJsOH:.::; .QH,cJ77Z: 1M  i: .7.7;,77U,: .;,:,,,,,.,,,,,,,.,,,,,,.
 17 //:.:,,,,,,,,,,...,,:, 1pwL;pHLr,::; :ELr:  sr  LO :r..vr r;:rsw,,.:s .:,,,,,,,,,,,,,,,,,,:.
 18 //,.,:,,,:,,,,,,,,.,. :Uv7:L627U,:::.LS2r,.:.   ;H.;::rc.  :.:72,:,7L, ::,,,,,,,,,,,,,,,,:,.
 19 //:.,,,,,,,,:,,,,,,,.,:;7:7KU17H;,::,PBBBBBBBX; :v:,,;v   :r. cS,:.w2 : ;,,,,,,,,,,,,,,,,,:.
 20 //,.,,,,,,,,,,,,,,,,,::c;7Uas17Xr::::sJsQBBBZSU .:.,;;..QBB6R;g5.:.RK.,. ;.,,,,,,,,,,,,,,,,.
 21 //:.:,:,,,,,,,,,,,,,;:7;cHKU7ssrJr:,:r  X7L5:   .,,:.  1BBU 7LBv.,:LE: : ,,.,,,,,,,,,,,,,,:.
 22 //,.,,,,,,,,,,,,,,,;,rrspJEU;Js;HJ7,:;     :    ,.     ;s2  :gG:.;7rgU:;, :. . ..,,,,,,,,:,.
 23 //:.:,,,:,,,,,,.,,::7wrL1JOw;rrwScX:::                      aOJ 7s:,gG;rM s1svr:. .,,,,,,,,.
 24 //,.,,,,,:,:,,,::::7Jr.7Jw6p:.1BLi1s,;                      gK.r5v,,1B .5::,:;ii65, ,,,,,,,.
 25 //:.:,,,,,,,,,::::;;: ,sSwKv.LSZLr7sr;;                    c6;72;,i rB,i,..     g,Hr .,,,,,.
 26 //,.,:,,,:,,,,,,,,....;s1S::SUrsr7r7L;ZL                  72rJS7  Q LRwg,7;.   LL .pL .,,,,.
 27 //: :,,,,,,,,,,,,,,,, ;L77LGwc7Lvr7rra1B5.      .       rU2rr6U;  B ,7:7HBBBBMZQ. . Js .,,:.
 28 //,.,:,,,,,,,,,,,,.,..rP:UgPi:2sc:rrrDSZS;7r,        rsJUsrrXX1; :B::B7OBMRQBBBBBr  :gs..,,.
 29 //: ,,,.,,,.,,,,,,,:rr;J:.22a:7,7,7;SH1aR:;rc7r:.,rSBpLsr:;SK;L  QBiLBsJBRRDBBBBB2: H.:s,.,.
 30 //,.,,,,,,.,.,,::;;r:, ,r: rpL :;,;sH1gBB:;rrrrr,BBBD7;:,,11,,  2BBLQBSrQK2GQr ;   ga  s:.,.
 31 //: ,,,,::;rrrr;;:,.,.,...::,  ;:.;BBQQBa.:::,,. MBB;,:. SD:..;MBQGRBBR;B2OBB   :   ,::v..,.
 32 //:,;7cJJs7r;:,,.,,,...:r7:   .;..UBROEB;..::::. RBr.:  JBBBHOBBpDggZRM7JXEBBL  ;:  :Bp7 ,,.
 33 //1sSsr::.......,...:;cv:     :.cLEBGZDQi:,   .,;Qw,:  aBgQLsQPs7rUOKPgJLO6BBr  ,  7BXXU..:.
 34 //r,.   .......,,;rsJs:      .:6Q1BBZggB.       .E:.  wBHEv:M5sJvc76pRRZrOZEpBHMP:,RDGO; ,,.
 35 //:.::::;:;;r7cLJLr,    ,,..;pBBaXR6HgRBw7wJ1s7LH;   ;D6KH.DZJws2X1ssJ5Zc5OEXgBBBBBROZ. ,,,.
 36 //::;r;rrrr7;;:,     ,,.  :6BBR.  ,: ,QB2.::  JG.   ,LDPpi7BwS1XX1LJXHXD27JKJK2OE6O6Zr ..,,.
 37 //. ..,,,,.             ;QBBBB.   ,,, :BU :  .:    :.SGHP:DSU2aZ2J1JJLU56LHG: rKZE6pp..,,,:.
 38 //;,,,..   ..,....,;rr::QBP6X.     . , cB.;; .,   ;r BHp6XgX12p6JU1JKpPaEJr2Q1  SE2g7 .,,,,.
 39 //;:7r;::::::,:;sssr:. :P1OO:     .  ,BRBJ. :U:   B ;BEMKsXpUwDXU251PUBUH2U7:rM7:;1S, ,,,,:.
 40 //vr;::;:::;7UEPr,.,,..ORBB,     sBBvPBQs .gQ:   QB 2BgQJsUSHXGKwSU5aJ51GSSQa  sMLr, ..,,,,.
 41 //Liv777LJXpgHL..,,,, 7BBBc ,   .BBOB6s  JBB;   ,Es MBgMssPPE6ZXUUS2HUvHBHJZDPr :Pi ..    , 
 42 //vrr7L2SaUai  ..,,,  DBQB.    :BOHpw, vBBB;.   EBs ZgRB7w2pDRKZ25U5SXsJOZLG6Ogg777cUHwsr:. 
 43 //c:2apa21J: .,,,,,. LBMBQRs::RBBBM, ,BQRBs..  5KQp gH5S;15aZMEPa1S2Pa2sJgwPZZZKEaSw2wSHE6P7
 44 // rgHs7s7..,,,,,,,..BBRRggBBBBBBr :EZPGBQ.,  7EHsP pMOa:1KEHMgPp512PXw2LGKsJJJ5UHSUUXS1v1SZ
 45 //SXLr71; .,,,,,:,, XBBRMZOORBBa  KBBHSsBL .  BJRrO cPKZHaGPPgMp665JZ52w1LEJJsJsscssUa6Xs1X6
 46 //s;rLw: ,,,,,,,,,. EgGQMgDRBQ, rBDKSDOSp  , ;BL6LE;.D2w5GpPPMggaEPUPSw2JswHU2Js1HUHPPXEaJPP
 47 //7;s1, ,,,,,,,,:. ,B6PKORQBS .gBRRDQRZBs  , gpcHaHp spS66pXOgRR6XZPOUU11ss1ZPPX1JsH6KPZK2ZH
 48 //77w, ,,,,,,,,:,. ZQpPHaZM; sBBggOgM2OB,  . B2UEppBL:HZEEHpRgDRgPKE6UU51wscSEORJs2EKPHOHPHG
 49 //Js,.,,,,,,,,,,, iQOPEUUZ: HLGBgDgMSrBE.   :B7aMOOZMrrXHXHGGZOOMEHp6152U1wLSgHpPLPPPX6DgOgR
 50 //K. ,,:,,,,,,,,..BBpEpSp7 pg :BRDgR:aBL.   JB:r1XpOOR77UKPgDgEOp6K6Zw2SU211spHZ65PpXKRgr::s
 51 //, ,,,,,,,,,,,, cBPpZXUK 5M;  aBDgK;BB::   DQvcw7r7JXRKapOGRgRRDgROES22XU21sw6pO56XHOs..   
 52 //..,,,,,,,,,,,, PB6PZ2pr:gZ,:.sBEKKHBE.:  .RBssRO6H2HEGZZpZODEOOZgDX65UXXwUJ2ZOOSHPZar11Lcr
 53 //: :,,,,,:,,,:, KBPZZSpv:OiJBBO6K6EQRK.:.  RQHiR6GGgORgO6DDMMREH6REHPZ2P2S5SJDgg66PpSUvL5G6
 54 //,.,,,,,,,,,,,, vBOORZRZ;:,BBOPpDRG;g5.:;  SBDrSDZZ2SGPPEpHXPMMPRDgOGP6HUUaUUPMgZaaJsLUHXSS
 55 //, :,,,,,,,,,,,.,MQQgar,::7QgOpZa7.7Q2.:::.rBgH7GKJUgOPZEK1wsUgBggDRRDZKwS5526ww12ss2paJcHU
 56 //. .,.,,,,,,,,,,..:,.    rK7rrr;:;2XR1.:::,.ZQQJ7aEBBQBBBgGpPSUQBBQZX5EpU15UUrJHXc7HKJ1JJaK
 57 //pr:.  ..........    ... ZBEJKXEggSSEK rrr;;:aOMK6BQ5Lr:..       ,:cP1PDaUJUpXGEZX7Zas1wsHX
 58 //SpgZJ7;:::,:::::;rr7r;,rQg7HPEEDKKapR.,;::::::::                   .2gREPaHBD5KHPpsE1JJJSP
 59 //. ;72XppEPS1wJwJwJJss7r;XBRORgB2raO6BJ ::.                           RgDp6pOQKaZHPpJGs1sXH
 60 //.  . ....,.,.,.,.,.,:::: 2BMEDB1 .:1RBJ,:;;;;;:;;rr7rr:,.wQBQU77:    6OgSPK6gMXP6H6HwZsJ5p
 61 //: ,,,.,.,.,.,.,.,.,......LBQROBL    ,rPs;::;rr7rr:,    rgQBEBQrsaw,  XRgEKHSpORa6PX6S5PvSK
 62 //,.,,,,,,,,,,,,,,,,,,,,,..7Kr;BgRL.        :r,,       7RBMgRBBRivv5J  XgGZRRRDMQQ5ZPHZUX5Jp
 63 //:.:,:,,,,,,,,,,,,,,,,.. . ; :gOQBBE;     ,.       ;HBBBgRRBQB2irL5. ipPpvaBBQgMBRSOHKEwPHH
 64 //,.,:,,,,,,,,,:,,.,.    ::1ppOgRMRBBBBQXr.7, .,:sEBBBMRRQQMBBPr::J; :HBa5LsaBggDBBBZDHP616K
 65 //:.:,,,,,,,,,,,,.  .;JZBBBBBBQggORRQMBBBp.;BBBBBBBQBMQMQRBQRwr:.:r r2GBBZaJJ1BBBBBBPRRa6p2P
 66 //,.,:,,,,,,,,,,.,rr6BBBQQRRgRgggRDRRBRQQ7.:PBBBBBQQBBQBQMpwr:,. 7ss5gZv.ZMa7.:src7, sBgUPPX
 67 //: ..,,,,,,,,,..sOpRQRggDRDggRgRRMRQDDgBg;,,LgQQRMgRRZwLrr;:..,s2UGOZa. JP  :: :.,,  UBgH6p
 68 //r;:,.......,..,1OaDQgggggRgRgQMQgDZ6ZMRBBSr,.:;;;;:::r;;,  :LZwSRDHGJ  gc  c,.i :.:  EBBQB
 69 //:.r::;:::::::;;iUvGBMgDERgMMQRgpHZOZORRQBBBEXsL7vsHG1,  ,iwHXRgZgPPGv  Bv .s  ::i.:, :H52s
 70 //:::;;r7sLscc7r.rXSUQDEpRgMMRZpaHKgEOGRMBDDDQMBBMOGs: ,7SpO6Z6BO6GPH6;  B:  7 .:,.,,; 7.   
 71 //7:r;r7Lssv7;:. ;OSS6EpgRBROXHHpKDDOZgRMEOEDDgZHLcrc5DBBgE6EHpBREEH6P2LsgJ.:7 .,.,,,:,;.., 
 72 //..:::;::,,..., :6SDBOgQBRGSHZOppgOZRRRZGEDOgE6PEOQBBRR6PKpKHXQMDKpPOEESgMD6QPc.,,,.::.,,,.
 73 //, ,.......,,,,..H5ORgMQX21aS5SZDMZRRQEGEDODpPPpKpEBDgZPKpKpaPQQ6pP6HKv7OgcpOX;..,,,,,,,,:.
 74 //,.,,,,,,,,,,,,. :PGgOGJJH65sLJJEQQgMgOOgOGPpP6PPSgQDZPKpH6HHPBMZPZPZU77RprPXr..,,,,,,,,,,.
 75 //:.:,:,,,,,,,,. ,2OQDDppHJ11J52wsKMBgEGRDGZE66p6XPRQ6PKpP6KpHDBQpOZZP17Sg57G57.,,,,,,,,,,:.
 76 //,.,:,,,,,,,,...PBQgMMGs;,:JH2UJ1J5DBgSwUSPp6pEKHOBDKK6PZ6E6HPBRPU2pPLLZOscE5r..,,,,,,,,,,.
 77 //:.:,:,,,,,,,, cQEEMML:,:;:;wUJJs1w5GZUsLJssXPaK6QBEKEZGEOH225X17;rg5LsgKvs61;.,,,,,,,,,,:.
 78 //,.,:,,,,,,,, :DQPGROi :;ri:r7wJ1J1USwHsvrrvZ6aUpQBpE6pXwrr;U6pss:vg2cUDU7XH1,.,,,,,,,,,,,.
 79 //:.:,,,,,,,,. 2gOZOg6Q::;.:r::rJ1S5pHpgL.:;.rBXSJ6aUJ1J2c7c,:RK2c:SgJcSGJcKPL..,,,,,,,,,,:.
 80 //,.,:,:,,,,. ;GZgZgZRMB:   ;7;::rr1SHHE1:i; ,gOS1LsLss22ag2,;7r::,ZE176KJcOa7 ,,,,,,,,,,:,.
 81 //:.,,,,,,,,..pPEgB7,BBB6    :7r;::::::::;;..:77JsLLJJ2UUs7r: ....;GELLGaLJOX:..,,,,,,,,,,:.
 82 //,.,:,:,,,. sGK6BP. cBpZg.    :;rrr;:::;;.,.:7,,::;;;;;;;;,   L;.;QaLsgUv2D1,.,,,,:,,,,,:,.
 83 //:.:,:,,,, :G6aRB:,:.sGpGM:      .:;;;;7.,,.:L:;;rir;;::    :GBBpOg27SOw76ps..,,,,,,,,,,,:.
 84 //,.,:,,,,..UZaKBc,;,..LZZPMs       .,,7,.,,.:i:;           7gBDOMUp5LKGLrEH; .,,,,,,,,,,:,.
 85 //:.,,,,,. ;BO6ga.:,:. .7HZp6P7     :.7:.,,..:E:.         rMBBEZDDwwgPRGH2g1c:..,,,,,,,,,,:.
 86 //,.,:,,,, sQBBQ,:.,:    :sXaDRgL.   r:.,,,, ;QB;     .rHBBBOga6OD12aZpE6EOppH:.,,,,,,,,,,,.
 87 //:.:,,,,. HgRB,. .,       :c2PPDBBG2..,,,,, ,BRBpL2EgBggZ2;.pPKRZLLJPUasJX5pL,.,,,,,,,,,,:.
 88 //,.,,,,,..MOBU:,..          .r5GQBB: ,,,,,,. QBBgDQQGr:   .;MXKgKLJaPLXXaLHJr.,,,,,,,,,,:,.
 89 //: :,,,, rBQORBBQD5JLv77vJsUDBBBQR. .,,,,:,..BQG6DXaJJ;  . JgPXg2JsE1JsPsJE1;..,,,,,,,,,,:.
 90 //,.,,,,. LBQrsZRBMBQBQRBBQBBRGXPP. .,,,,,,,.:7. ,7GOEOgDQZJ66HPG1LUPJJ5asaEJ:.,,,,,,,,,,,,.
 91 //: :,,,  5QJ ,,::r7sLsvL7r;:. .; ..,,,,,,,,.:r ..  :cZRBBBBDaK6GLJXHLJX1JDXs..,,,,,,,,,,,:.
 92 //,.,:,. 1BO,..,,.            .r..,,,:,,,,,:.:r.,:      ,J2OEHXDassEUJUKLXDXr .,,,,,,,,,,:,.
 93 //:.:,, wBB;..:::            :7,,,:,:,:,:,:,,:L.::,        sBSPO1swG5sKULpO2:.:,:,:,:,:,:,:.
 94 //: ..  :Bs  ..,            ,; ............. .r ..,      ,.wBGK5rL2EJs5scP57  ............. 
 95 
 96 
 97 #include <iostream>
 98 #include <cstdlib>
 99 #include <cstdio>
100 #include <algorithm>
101 #include <string>
102 #include <cstring>
103 #include <cmath>
104 #include <map>
105 #include <stack>
106 #include <set>
107 #include <vector>
108 #include <queue>
109 #include <time.h>
110 #define eps 1e-10
111 #define INF 0x3f3f3f3f
112 #define MOD 1000000007
113 #define rep0(j,n) for(int j=0;j<n;++j)
114 #define rep1(j,n) for(int j=1;j<=n;++j)
115 #define pb push_back
116 #define set0(n) memset(n,0,sizeof(n))
117 #define ll long long
118 #define ull unsigned long long
119 #define iter(i,v) for(edge *i=head[v];i;i=i->nxt)
120 #define max(a,b) (a>b?a:b)
121 #define min(a,b) (a<b?a:b)
122 #define print_rumtime printf("Running time:%.3lfs
",(long double)(clock())/1000.0);
123 #define TO(j) printf(#j": %d
",j);
124 //#define OJ
125 using namespace std;
126 const int MAXINT = 100010;
127 const int MAXNODE = 100010;
128 const int MAXEDGE = 2 * MAXNODE;
129 char BUF, *buf;
130 int read() {
131     char c = getchar(); int f = 1, x = 0;
132     while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); }
133     while (isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); }
134     return f * x;
135 }
136 char get_ch() {
137     char c = getchar();
138     while (!isalpha(c)) c = getchar();
139     return c;
140 }
141 //------------------- Head Files ----------------------//
142 int x_s, x_l, y_s, y_l, n;
143 long double lb = -1e50, rb = 1e50;
144 struct mouse {
145     int vx, vy, sx, sy;
146     mouse(int _sx, int _sy, int _vx, int _vy) {
147         sx = _sx; sy = _sy; vx = _vx; vy = _vy;
148     }
149     mouse() {}
150     long double intersect(int p, int tp) {
151         long double t;
152         if (tp == 1) { //x=p;
153             t = ((long double)(p)-sx) / vx;
154             long double py1 = sy + vy * (t + eps);
155             long double py2 = sy + vy * (t - eps);
156             if (((t + eps > 0) && (py1<y_l && py1>y_s)) || ((t - eps > 0) && (py2<y_l && py2>y_s))) return t;
157             return -1;
158         }
159         if (tp == 2) { //y=p
160             t = ((long double)(p)-sy) / vy;
161             long double px1 = sx + vx * (t + eps);
162             long double px2 = sx + vx * (t - eps);
163             if (((t + eps > 0) && (px1<x_l && px1>x_s)) || ((t - eps > 0) && (px2<x_l && px2>x_s))) return t;
164             return -1;
165         }
166     }
167     int in() {
168         return (sx < x_l && sx > x_s) && (sy < y_l && sy > y_s);
169     }
170 } mice[MAXINT];
171 int intersect(long double l, long double r) {
172     lb = max(l, lb);
173     rb = min(r, rb);
174     if (rb - lb < eps) return 0;
175     return 1;
176 }
177 void get_input();
178 void work();
179 int main() {
180     get_input();
181     work();
182     return 0;
183 }
184 void work() {
185     rep0(i, n) {
186         long double t, l = 1e50, r = -1e50;
187         if (mice[i].in()) {
188             l = 0;
189             if (mice[i].vx == 0 && mice[i].vy == 0) r = 1e50;
190         }
191         if ((t = mice[i].intersect(x_s, 1)) > -eps) l = min(l, t), r = max(r, t);
192         if ((t = mice[i].intersect(x_l, 1)) > -eps) l = min(l, t), r = max(r, t);
193         if ((t = mice[i].intersect(y_s, 2)) > -eps) l = min(l, t), r = max(r, t);
194         if ((t = mice[i].intersect(y_l, 2)) > -eps) l = min(l, t), r = max(r, t);
195         if (r - l < eps) {
196             printf("-1
");
197             return;
198         }
199         if (!intersect(l, r)) {
200             printf("-1
");
201             return;
202         }
203     }
204     printf("%.10Lf
", lb);
205 }
206 void get_input() {
207     n = read();
208     int x1 = read(), y1 = read(), x2 = read(), y2 = read();
209     x_s = min(x1, x2);
210     x_l = max(x1, x2);
211     y_s = min(y1, y2);
212     y_l = max(y1, y2);
213     rep0(i, n) {
214         mice[i].sx = read();
215         mice[i].sy = read();
216         mice[i].vx = read();
217         mice[i].vy = read();
218     }
219 }
许愿弥生改二
原文地址:https://www.cnblogs.com/LoveYayoi/p/6756607.html