#K80617. Missile Strike
Missile Strike
Missile Strike
You are given an \( N \times N \) grid and \( M \) ships located at specified coordinates. A missile is fired at a given coordinate. Your task is to determine whether the missile hits any ship. A missile is said to hit if its coordinates exactly match the coordinates of any ship on the grid.
Note: Coordinates are 0-indexed.
Input: The input is read from standard input (stdin). The first line contains two integers \( N \) and \( M \). The next \( M \) lines each contain two integers representing the coordinates of a ship. The last line contains two integers representing the missile's target coordinates.
Output: Print HIT
if the missile hits any ship, otherwise print MISS
. The output should be written to standard output (stdout).
inputFormat
The first line contains two integers \( N \) (the grid size) and \( M \) (the number of ships) separated by a space. The next \( M \) lines each contain two space-separated integers denoting the coordinates of each ship. The final line contains two space-separated integers representing the missile's coordinates.
outputFormat
Output a single string: HIT
if the missile's coordinates match any of the ships' coordinates, or MISS
if it does not.
5 3
0 0
1 2
3 4
1 2
HIT