Problem A
Snóker
Languages
en
is

Arnar has been watching snooker recently. Snooker is played
on a large rectangular table and the players use a cue, which
is just a custom made stick. The play area on the table is
There are also balls on the table in multiple colours and
each colour has purpose. The radius of each ball is
Colour |
Points |
Red |
|
Yellow |
|
Green |
|
Brown |
|
Blue |
|
Pink |
|
Black |
|
Each time the white ball is hit, a certain colour is designated as the first colour to hit with the white ball, known as the on colour. Each time the correct colour is pocketed by a player, the player gets to hit the white ball again. If there is a red ball on the table when a player starts their turn, then red is the on colour. If the player pockets a red, then they can choose the on colour, except for red, for their next shot. If the player pockets a coloured ball on that shot, then the coloured ball is placed on the table again after points have been awarded. After that shot, the on colour is set to red again.
If the white ball hits the right colour first, then the shot is a HIT. If the white ball hits the wrong colour first, then the shot is a FOUL. If the white ball does not hit any ball, then the shot is a MISS. Note that the white ball can hit the sides of the table as many times as possible, both before hitting a ball, and after.
One of the goals of the game is to snooker the opponent, by hitting the white ball so it is poorly placed for the opponent. At that point it can prove difficult to hit a correct ball, and a direct shot may not be possible. The white ball is then usually shot so that it bounces off the sides of the table before hitting a ball. Since it can be difficult to visualize the bounces, Arnar wants you to tell him whether the white ball hits a correct ball.
You are given the current state of the table, the on colour and a description of how the white ball will travel after being hit with the cue. Determine whether the shot is a HIT, a FOUL, or a MISS. To simplify the task, you may assume there are no pockets on the table, so the white ball cannot be pocketed, but rather always bounces off the sides upon hitting them.
Input
The first line of input contains a single integer
The colours of the balls are described by the strings
white, red,
yellow, green, brown,
blue, pink
and black. There can be up to
Output
Output HIT if the white ball hits
the correct colour first, FOUL if the
white ball hits the wrong colour first, or MISS if the white ball does not hit any ball.
You may assume the answer will not change if the positions of
the balls change by less than
Scoring
Group |
Points |
Constraints |
1 |
30 |
The white ball does not travel far enough to reach a
side of the table. Either |
2 |
20 |
Either |
3 |
25 |
The white ball does not travel far enough to reach a side of the table. |
4 |
25 |
No further constraints. |
Explanation of samples
The first sample belongs to group
![\includegraphics[width=0.7\textwidth ]{sample1}](/problems/snoker/file/statement/en/img-0002.png)
The second sample belongs to group
![\includegraphics[width=0.7\textwidth ]{sample2}](/problems/snoker/file/statement/en/img-0003.png)
The third sample belongs to group
![\includegraphics[width=0.7\textwidth ]{sample3}](/problems/snoker/file/statement/en/img-0004.png)
The fourth sample belongs to group
![\includegraphics[width=0.7\textwidth ]{sample4}](/problems/snoker/file/statement/en/img-0005.png)
Sample Input 1 | Sample Output 1 |
---|---|
2 white 35.000 1.000 black 35.000 29.000 black 0.000 50.000 |
HIT |
Sample Input 2 | Sample Output 2 |
---|---|
3 white 35.000 80.000 black 35.000 29.000 pink 34.000 40.000 black 0.000 1000.000 |
FOUL |
Sample Input 3 | Sample Output 3 |
---|---|
7 white 30.000 28.000 green 23.500 29.000 brown 35.000 29.000 yellow 46.500 29.000 blue 35.000 70.250 pink 35.000 105.500 black 35.000 127.750 yellow 10.000 100.000 |
FOUL |
Sample Input 4 | Sample Output 4 |
---|---|
22 black 35.000 127.727 pink 35.000 105.375 blue 35.000 70.250 brown 35.000 28.100 green 23.333 28.100 yellow 46.667 28.100 red 35.000 107.625 red 33.998 109.362 red 36.002 109.362 red 32.995 111.099 red 35.000 111.099 red 37.005 111.099 red 31.992 112.836 red 33.998 112.836 red 36.002 112.836 red 38.008 112.836 red 30.990 114.573 red 32.995 114.573 red 35.000 114.573 red 37.005 114.573 red 39.010 114.573 white 39.550 24.440 red -104.181 431.898 |
MISS |