You wake up to find yourself in an airless, friction-less, gravity-less arena armed with an object that bounces perfectly off any surface. Targets are appearing at one end of the room and you have to hit as many of them as you can. You can throw the ball directly at a target, or bounce it off the side walls before hitting the target. However, it doesn't count if you hit the wall behind the target before hitting the target.
The diagram below shows three different attempts to hit a target. The two red lines have hit the target, whereas the remaining pink line has missed. The ball always bounces perfectly, which means the angle with which it hits the wall is the same as the angle with which it leaves the wall (one example is shown as
For specifying locations and speeds, you can consider the arena to be on a Cartesian plane with the origin at the bottom left corner. You can treat the target and walls of the arena as line segments and the ball as a point on the plane.
The input will contain
The first line contains
The next
For each test case, your program should output a single line containing an H
or M
character for each of the five targets in the order they appear. Output an H
if the ball would hit the target or M
if it would miss.
Note that the sample data below contains only
Sample Input
116 178 53 41 7 16
43 101 73
32 64 128
13 62 119
23 55 63
44 74 54
137 122 11 24 7 16
20 123 50
30 130 70
15 29 32
23 79 67
12 39 66
Sample Output
MMMHM
HHMHM
Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org
Comments