DUMBPROB - Are you smart enough
Little Johny as we all know is very playful and he loves to solve geometrical problems.He is really smart too (yes seriously he is smart enough to write programs for very complex tasks). One day he wrote the following piece of code:
int flag = 0; for(int i = a; i <= b; i++){ if (i == c) flag = 1; } if (flag == 1) printf("Yes, the point c is between point a and b\n"); else printf("NO, the point c is not between a and b\n");
Little Johny wrote the above piece of code to find whether the one-dimensional integral point c is between a and b or not (and he thinks he is really smart after writing this code.)
Another day he decided to write a program for finding whether a two dimensional integral point (x, y) is inside a rectangle (the edges of the rectangle are parallel to the x or y axis). He realized that he cannot do it in time so he asks you for help .Your task is to write a program for finding whether a point (x, y) lies inside a given rectangle or not.
Input
The rectangle will be describe by the lower left point (X, Y) followed by the base B and height H.
(So the coordinates of the rectangle are (X, Y), (X + B, Y), (X + B, Y + H), (X, Y + H) in anti-clockwise order).
You will be given many points to process. For each point either print "OUTSIDE" if the point is outside the rectangle or print "INSIDE" if the point is inside the rectangle in a new line (Quotes are only for clarity you dont have to print it in the output.)
The last point will be (0, 0) you have to stop processing data after that.
Note: all numbers in the input will be between 1 and 10^8 inclusive and no point will be on the rectangle itself.
Input format
X Y B H
X1 Y1
X2 Y2
...
0 0
Example
Input: 10 15 10 20 11 17 15 25 23 67 54 76 2 9 14 30 0 0 Output: INSIDE INSIDE OUTSIDE OUTSIDE OUTSIDE INSIDE
Added by: | Ranjith Mudalaiyar |
Date: | 2012-05-23 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | own problem |