Richard and Cylinder
All submissions for this problem are available.
Richard loves Geometry. One day he was playing with a rectangle and a cylinder and came up with a problem.
There is a rectangle with sharp edges, kept in an x-y coordinate system. And there is also a cylinder of height 2 units (One unit above the x-y plane and one unit below x-y plane) placed vertically in the same x-y coordinate system.
Richard is going to insert a pin in any of the four corners of the rectangle and rotate the rectangle about that pin.
Rotation of the rectangle will be along the x-y plane.
He wants to know whether he can cut the cylinder fully into two parts.
Input rectangle will be a standard rectangle; i.e., their sides are parallel to the coordinate axis.
First four lines will contain two space separated integers each x and y, which represents the corners of the rectangle.
Fifth line will contain an integer Q, number of queries.
Each query will contain five space separated integers (x y p q r), where x and y represents one of the four corners of the rectangle where the pin has to be inserted. p and q represents the centre of the cylinder. r represents the radius of the cylinder.
For Each Query Print YES, if the cylinder can be fully cut into two parts, else print NO.
-10^7 ≤ x, y ≤ 10^7
-10^7 ≤ p, q ≤ 10^7
-10^7 ≤ r ≤ 10^7
1 ≤ Q ≤ 10^3
3 3 5 2 2
3 1 6 2 1
3 3 7 2 2
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.