Problem F
Compass Rose

Your friend Rose works as an intern at the United States
Geologic Survey (USGS) on Mines campus. She has taken you up to
a geological site in Boulder and given you some locations at
which you are to take geological measurements. Her instructions
to get to these locations include headings that you’re having
trouble decoding. These headings are strings consisting of
between one and ten cardinal directions (N, S, E, and W) and
correspond to an angle that you can set your compass to, to
travel in the right direction. For example, the heading WSW
corresponds to the angle
Headings are defined as follows.
-
Single character headings (N, S, E, and W) correspond to
, , , and , respectively. -
Two character headings (NE, NW, SE, SW) correspond to
, , , and , respectively. -
Headings of length
are composed of a valid heading of length , with one of the characters in that heading prepended to it, to add additional specificity to the heading.For example, we take the heading NE (
) but would like to add more specificity. We can prepend either N to form NNE ( , halfway between and ) or E to form ENE ( , halfway between and ).Similarly, we can form NNNE (
, halfway between and ) and ENNE ( , halfway between and ) from NNE by prepending N or E, respectively. However, we cannot prepend S or W (forming SNNE or WNNE) because NNE only contains the cardinal directions N and E, and so we can only prepend those characters to it.
Input
The first line of input contains
Output
You should output
Answers within
Sample Input 1 | Sample Output 1 |
---|---|
2 W N |
270 0 |
Sample Input 2 | Sample Output 2 |
---|---|
6 NW ESE ENNE SESE WNNNW WWWSW |
315.0 112.5 33.75 123.75 343.125 264.375 |