Introduction
The arena is a flatland dotted with skyscrapers, which your enemies use for cover. You and your enemies shoot each other with lasers. All of you carry jet packs, allowing flight.
Which enemies can you hit with your laser, and which are hiding?
Problem
First, the size of an arena is given by an integer n
on a single line. The following n
lines contain n
integers per line separated by a space. Each integer represents the height of the building at that location. Each building is a rectangular solid, 1 unit by 1 unit by height units.
Next, your location is given on a single line as three floating point numbers x
, y
, z
.
Finally, the number of enemies are given by an integer m
on a single line. The following m
lines contain three floating point numbers per line separated by a space. These represent the x
, y
, and z
coordinates of an enemy. The coordinate system is defined as follows:
x
is measured from left to right in the city inputy
is measured from top to bottomz
is measured from the ground up
For each enemy, if an unobstructed line can be drawn from you to that enemy, output a positive integer. Otherwise, output a negative integer. Separate outputs with a new line.
Sample Input
Comments, denoted by '#', are present to help you quickly see what each line does. They will not be present in the actual input.
5 # Size of the map
0 0 0 0 0 # Buildings
0 0 0 0 0 # Buildings
4 4 4 4 4 # Buildings
0 0 0 0 0 # Buildings
0 0 0 0 0 # Buildings
2.5 0.0 4.0 # Your location
3 # Number of enemies
2.5 5.0 0.1 # Enemy location
2.5 5.0 5.0 # Enemy location
0.0 2.7 4.5 # Enemy location
Sample output
For the sample input above, we output the following:
-1
1
1
Assumptions
- 0 <
n
< 100 - 0 <
m
< 100 - 0 <=
x
<=n
- 0 <=
y
<=n
- 0 <=
z
<n
- Players will not be located on or inside of a corner, edge, or side of a building
- Your line of sight to an enemy will never be tangent to the corner, edge, or side of a building
- A player is not an obstruction