Problem F - 2018
As you all know, Frank Lin likes to go mountain climbing. Unlike lonely Roy who celebrates New Year’s Eve at the dorm himself, Frank decides to watch the smoky sunrise in the mountains at the beginning of 2018. Before the journey, Frank plans n different routes to climb up the mountain. Given the n different routes, your task is to find out how many different locations these routes will end up with.
You can consider the whole journey and the location as lines and points on the coordinate plane system. Frank will start his journey at point (0, 0). The route representation contains only four characters ‘N’, ‘S’, ‘E’, and ‘W’ which stands for that Frank moves up, down, right, or left one unit parallel to the y-axis (‘N’ and ‘S’) or the x-axis (‘E’ and ‘W’) respectively.
source : http://www.ysnp.gov.tw
The input consists of a single test case in the following format.
n
s1
s2
...
...
sn
The first line contains an integer n satisfying 1 ≤ n ≤ 2000. n denotes the total number of different routes to climb up the mountains. The next n lines show the directions of routes. The i-th line of them contains a string si with only four characters ‘N’, ‘S’, ‘E’, and ‘W' whose length is between 1 and 100, inclusive, which is the information of the i-th route.
Print the number of locations these routes will end up with.