Problem E
Golden Landmarks

The city of Golden has many landmarks worth visiting. Before
arriving in Golden, you made a list of landmarks you want to
visit and the order in which you will visit them. To understand
where these landmarks are located, you create a map of Golden
and mark each landmark on it. You determine the
Since Golden is laid out on a grid, the walking distance
between two landmarks at coordinates
Input
The first line of input contains an integer
The next
The final line contains a space-separated sequence of
Output
Output a single integer, the total walking distance required to visit all landmarks in the specified order.
Sample Input 1 | Sample Output 1 |
---|---|
2 CTLM 1 1 MinesMarket 2 2 MinesMarket CTLM |
2 |
Sample Input 2 | Sample Output 2 |
---|---|
5 ClearCreek 0 0 MinesM 20 10 SouthTable -20 -10 WoodysPizza 10 10 ColoradoSchoolOfMines 20 -10 ColoradoSchoolOfMines ClearCreek WoodysPizza SouthTable MinesM |
160 |