Helicopter
Time Limit: 1 Second Memory Limit: 32768 KB
"Helicopter" is a tiny game, in which you control a helicopter to fly through a tunnel (Figure 1). You can assume the width of the tunnel is infinite, but remember your helicopter can never hit the ceiling or the floor of the tunnel, otherwise it will immediately get crashed.(Figure 2) Besides the ceiling and the floor, there will be some blocks floating in the tunnel and you can not hit them either.
To simplify the problem, we can set up a coordinate system as below.
The ceiling and the floor are not flat but bumpy. The lowermost of the floor
is 0 by y-coordinate, and the peak of the ceiling is 100 by y-coordinate. All
the blocks have the same height of 30 and a width of 1. The helicopter has a
width of 3 and you should prevent any part of it from touching the ceiling,
the floor or the block.
You can control the helicopter only by the left button of your mouse. The initial
y-coordinate of the helicopter is 50. When the game begins, the helicopter starts
to fly into the tunnel and forward right at a fixed horizontal velocity, 1 unit/sec.
And because of the acceleration of gravity, it also has a downward acceleration
which is 1 unit/sec^2. When you press the left button, the helicopter will have
an upward acceleration which is 2 units/sec^2.
Notice that, the duration between the instant when you press down the button
and the instant when you release it must be n units of time (n is an integer).
The crash will happen only at the integer points of y-coordinates.
Now, given a map of the tunnel, you are supposed to figure out whether the helicopter
can finish the flight.
Input
First line of input contains an integer m, which is the number of tests to
process. For each test:
The first line contains an integer n (0 < n <= 1000), which is the length
of the tunnel. In other words, if your helicopter manages to arrive at the point
(n-1, x) without being crashed, then you finish the flight.
The second line contains n integers, c[0] ... c[n-1] (55 <= c[i] <= 100
for i = 0 ... n-1), indicating the y-coordinates of the ceiling.
The fourth line contains n integers, b[0] ... b[n-1] (b[i] = -1 or f[i] <=
b[i] <= c[i] - 30 for i = 0 ... n-1), the bottom y-coordinates of the blocks.
If b[i] = -1, it indicates that there is no block.
The third line contains n integers, f[0] ... f[n-1] (0 <= f[i] <= 45 for
i = 0 .. n-1), indicating the y-coordinates of the floor.
Output
For each test, output '8-)', if you can control the helicopter to finish the
flight, or '~><~' otherwise.
Notice, there should be no redundant space or blank in your output.
Sample Input
2 3 90 90 90 -1 -1 -1 10 10 10 5 90 90 90 90 90 -1 -1 -1 40 40 10 10 10 10 10
Sample Output
8-) ~><~Submit
Source: Zhejiang University 2003 Summer Camp Qualification Contest