MEC '16 P1 - Bat-Doctor

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Alfred Pennyworth is Batman's loyal butler. As such, whenever Batman returns to the Batcave wounded, it is Alfred's job to tend to him. Most of the time, Batman's problems can be fixed with just a few stitches, and Alfred is a master at needlework. After one especially bloody night, the Dark Knight returns home, severely wounded. Normally, Alfred would easily be able to stitch up the wounds, but that very night was the night that the Riddler decided to cut off the power in all of Gotham. Alfred has asked you, Captain Nightvision, with your super powerful night vision, to guide him in his stitching. Given Batman's wounds as a grid, give Alfred directions to close up the wound.

Batman's wounds appear as a grid of the characters X and O, with X representing the points that Alfred's needle must pass through. Starting from the left most stitch point and going to the right, you must tell Alfred at what angle to make each stitch in order to reach the next point that Alfred's needle must pass through.

Input Specification

The first line of input will contain two integers, R and C (1 \le R, C \le 10^4).

The next R lines will contain C characters, mapping out Batman's wound. It is guaranteed that there will be a maximum of one X per column.

Output Specification

Output the angle of each stitch, starting for the center of each X, clockwise from the north bearing in degrees, precise to 3 decimal places.

If no angles exist, output 0.000.

Sample Input

3 6
XOOOXO
OOXOOO
OXOOOX

Sample Output

153.435
45.000
63.435
153.435

Sample Explanation

The order in which the stitches are made is:

1OOO4O
OO3OOO
O2OOO5

For the first 2 points, the angle is found like so:

This is continued for every pair of consecutive points.


Comments

There are no comments at the moment.