Wow much parking lot

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 16M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Junior 2 — Wow much parking lot

Griffy has made it past all of Don Mills's plushies, and has ended up in their parking lot! However, having bumped into so many plushies, Griffy's mind is not very clear. After a while strolling around, instead of reaching the school Griffy is now lost! Please help Griffy find where he ended up! Griffy started at the relative position (0, 0), and you know the sequence of moves he took. Griffy took N moves, each move consisting of a pair: A (direction) and B (distance). Where in Don Mills could Griffy have possibly ended up?

Note: coordinate format will be (x, y). Going north increases the y value, going east increases the x value, and the opposite is true for south and west.

Input Specification

The first line will contain a single integer N (1 \le N \le 50).

Next 2N lines will contain pairs of commands: A and B on separate lines.

A will be one of four possible directions: North, South, West, East (capitalized, no spaces).

B will be an integer (1 \le B \le 20).

Output Specification

One line, the coordinates where Griffy ends up, space separated.

Sample Input


Sample Output

5 -1


  • -6
    alpturkmen  commented on Jan. 28, 2015, 1:03 p.m.

    This comment is hidden due to too much negative feedback. Click here to view it.

    • 7
      BMP  commented on Jan. 28, 2015, 1:07 p.m.

      Griffy started at the relative position (0,0). I assume reading the statement could help :P.

      • 1
        alpturkmen  commented on Jan. 28, 2015, 7:02 p.m.

        How did i miss that ? -_- My bad, thanks!