| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 10 | 9 | 9 | 100.000% |
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 247ドル.5^{\circ}$. Rose's instructions include a lot of these headings, but you don't have their corresponding angles memorized, so you decide to write a quick script to do the conversions for you.
Headings are defined as follows.
\item Single character headings (N, S, E, and W) correspond to 0ドル^{\circ},ドル 180ドル^{\circ},ドル 90ドル^{\circ},ドル and 270ドル^{\circ},ドル respectively.
\item Two character headings (NE, NW, SE, SW) correspond to 45ドル^{\circ},ドル 315ドル^{\circ},ドル 135ドル^{\circ},ドル and 225ドル^{\circ},ドル respectively.
\item Headings of length $n \geq 3$ are composed of a valid heading of length $n - 1,ドル 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 (45ドル^{\circ}$) but would like to add more specificity. We can prepend either N to form NNE (22ドル.5^{\circ},ドル halfway between 0ドル^{\circ}$ and 45ドル^{\circ}$) or E to form ENE (67ドル.5^{\circ},ドル halfway between 90ドル^{\circ}$ and 45ドル^{\circ}$).
Similarly, we can form NNNE (12ドル.25^{\circ},ドル halfway between 0ドル^{\circ}$ and 22ドル.5^{\circ}$) and ENNE (33ドル.75^{\circ},ドル halfway between 22ドル.5^{\circ}$ and 45ドル^{\circ}$) 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.
The first line of input contains 1ドル \leq n \leq 1,000円,ドル the number of test cases to follow. Each of the following $n$ lines contains a heading $D$ such that 1ドル \leq |D| \leq 10,ドル that is, each heading will be at most 10ドル$ characters. You may assume that all headings given follow the definition provided above, and there will not be any invalid headings.
You should output $n$ lines, with the $i^{\text{th}}$ line containing a real number, the compass heading (in degrees) corresponding to the given heading $D_i$.
Answers within 10ドル^{-8}$ of the correct answer will be accepted. If a compass heading does not contain a decimal portion, it can be omitted.
2 W N
270 0
6 NW ESE ENNE SESE WNNNW WWWSW
315.0 112.5 33.75 123.75 343.125 264.375
School > CS@Mines > CS@Mines HSPC 2023 > Beginner G번
School > CS@Mines > CS@Mines HSPC 2023 > Advanced F번