- #1
Wanna-be Eng.
- 2
- 0
Homework Statement
Problem Destruction Droid Introduction Life was easy and happy on the third moon of Sirius 8: people lived and worked in the many peaceful
colonies. However, the Klingon Empire decided to extend its control to this part of the galaxy: they
landed a Destruction DroidTM
on the surface of the moon. The Destruction DroidTM
will go to one
colony and destroy it completely. If we knew which colony is targeted by the Destruction DroidTM, then
we could concentrate our forces to defend that colony. Fortunately, we have intercepted the commands
transmitted to the Destruction DroidTM, thus it is possible to determine its destination. Your task is to
write a program that determines the unfortunate colony where the Destruction DroidTM
goes.
One of the nice things about this moon is that it is almost completely flat, hence everything can be
described easily with two coordinates. East is x
direction, North is y
direction.
Input Each input file begins with a line containing four integers:
n<=500, the number of commands,
m<=100, the number of colonies,
x and y, the starting coordinates of the Destruction DroidTM
The first line is followed by n
lines containing one command each. There are 5 different commands:
LEFT p : turn left p degrees
RIGHT p : turn right p degrees
FASTER p : increase the speed with p units
SLOWER p : decrease the speed with p units
WAIT p : the Destruction DroidTM goes for p time units in the current direction with the current speed
Speed is given in coordinate units per time units. It can be assumed that the commands do not increase
the speed above 500 or below 0. After landing, the Destruction DroidTM faces North(y direction), and
its speed is 0. The commands LEFT, RIGHT, FASTER, and SLOWER are executed in zero time: the
Destruction DroidTM does not move during these commands.
The last m lines of the input describe the colonies. Each lin ebegin swith a name of length at most 20,
which does not contain any space characters. The name is followed by the two coordinates of the colony.
Output You have to output the name of the colony where the Destruction DroidTM will be after executing the
commands.
Write a newline character afterthe name ofthe colony. It canbe assumedthattheDestruction DroidTM will be at a distance of at most 10 from some colony, and there is a unique such colony. It is possible that the Destruction DroidTM goes through some other colonies while executing the commands, but we do not care about that. Sample Input 5 4 0 0
FASTER 10
WAIT 10
RIGHT 135
SLOWER 5
WAIT 28
Aaaa 0 0
Bbbb 100 100
Cccc 0 100
Dddd 100 0
Sample Output
Dddd
Homework Equations
all c++ you can get
The Attempt at a Solution
I was thinking about using functions. Is it necessary to use clases? I'm not sure how to make the program calculate the last position of the droid. I'll come up with some code, probably tommorrow.
Last edited: