Can some one help me with this problem

https://codeforces.com/contest/1351/problem/C

Just use a map of pairs. First store `{0, 0}`

(`{x, y}`

) in the map (initial position). Then for each character in the string, simulate the process.

Consider sample 2.

Start at `{0, 0}`

. Then store `{0, 1}`

(because we have ‘N’) in the map and add 5 seconds to the total time sice this pair didn’t exist in the map. Now we have ‘S’. `{0, 1-1}`

= `{0, 0}`

which already exists. Don’t add it again. Since it exists, add 1 second to the total time. Answer = 6.