Follow a start point and a series of compass moves to compute the final coordinates, rounded to 8 decimals.
Easy2ImplementationMathSimulationNo attempts yetTime limit2sMemory limit512 MBYou inherited a treasure map from a long dead ancestor who was a pirate. Instead of a picture with a big X on it, the map is a list of instructions that walks you to the spot where you should start digging.
The first instruction is the starting location, given as two integers x and y. Every later instruction is a direction and a distance. N 7 means walk 7 feet north, and SW 6 means walk 6 feet southwest. Follow all of them in order and you end up standing over the digging spot.
Moving north increases y and leaves x unchanged. Moving east increases x and leaves y unchanged. A diagonal move of d feet changes both coordinates by d/2. NE adds d/2 to x and to y, SE adds it to x and subtracts it from y, SW subtracts it from both, and NW subtracts it from x and adds it to y.
Walking the whole route one instruction at a time takes a while, so compute the final location and go straight there.
One more thing: the ancestor was a Pittsburgh Pirate, and the treasure is a pile of old baseballs and a very moldy mitt.
The first line contains one integer n (1≤n≤100), the number of instructions.
Each of the next n lines contains one instruction. The first instruction is two integers x and y (0≤x,y≤100), the starting point. Each remaining instruction has the form dir d, where dir is one of N, NE, E, SE, S, SW, W, NW and d (1≤d≤100) is the distance to walk.
Print the x and y coordinates of the final location on one line, separated by a single space. Round both values to 8 decimal places and always print exactly 8 digits after the decimal point.
Every coordinate is either an integer or an irrational number, so it never lands exactly on a rounding boundary. When a coordinate is zero, print 0.00000000 and not -0.00000000.