ECOO '16 R3 P2 - Target Practice

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 2.5s
Memory limit: 64M

Problem types

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 α below) and it never loses any speed on a bounce.

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 10 test cases. Each test case consists of 6 lines.

The first line contains 6 integers Aw,Ah,Bx,By,Sx,Sy separated by spaces. These integers represent an arena and a single throw of the ball.

Aw and Ah represent the width and height of the arena (100Aw,Ah1000).
Bx and By represent the initial position of the ball you are throwing (1Bx12Aw and 1By12Ah).
Sx and Sy represent the X and Y components of the speed with which you are throwing the ball (0Sx100 and 1000Sy1000).

The next 5 lines each contain 3 integers Th,Tx,Ty separated by spaces. Each set of integers represents a possible target. Tx and Ty represent the location of the top of the target and Th represents its height (1Th14Ah and Bx+1TxAw2 and 14AhTy34Ah).

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 2 test cases, but the actual data files will contain 10 each.

Sample Input

Copy
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

Copy
MMMHM
HHMHM

Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org


Comments

There are no comments at the moment.