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 \alpha 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 A_w, A_h, B_x, B_y, S_x, S_y separated by spaces. These integers represent an arena and a single throw of the ball.

A_w and A_h represent the width and height of the arena (100 \le A_w, A_h \le 1000).
B_x and B_y represent the initial position of the ball you are throwing (1 \le B_x \le \frac{1}{2}A_w and 1 \le B_y \le \frac{1}{2}A_h).
S_x and S_y represent the X and Y components of the speed with which you are throwing the ball (0 \le S_x \le 100 and -1000 \le S_y \le 1000).

The next 5 lines each contain 3 integers T_h, T_x, T_y separated by spaces. Each set of integers represents a possible target. T_x and T_y represent the location of the top of the target and T_h represents its height (1 \le T_h \le \frac{1}{4}A_h and B_x + 1 \le T_x \le A_w - 2 and \frac{1}{4}A_h \le T_y \le \frac{3}{4}A_h).

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

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

There are no comments at the moment.