11507-bender B. Rodríguez Problem
Time limit:4.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem &problem=2502
Bender is-a robot built by Mom's friendly robot company at it plant in Tijuana, Mexico in 2996. It is abending-unit serial number 2716057 and chassis number 1729. He is created for the task of bending metal wires. Bender needs to bend a wire of length L (l
2 an integer). The wire is represented in the Bender's brain (AMOS Technology 6502 microprocessor) as a line stucked in the origin of a T ridimensional Cartesian coordinate system, and extended along the x positive axis (+x), so that the fixed extreme of the W The coordinate (0,0,0) and the free extreme of the ire are in the wire (coordinate).
Bender bends the wire at specific points, starting on the point (l-1,0,0) and ending in the point (1,0,0). For all I from L-1 to 1, Bender can take one of the following decisions:
Not to bend the wire in point (i,0,0).
To bend the wire at point (i,0,0) a angle of
To is parallel to the axis +y, y, +z or-z. For example, if l=3 and Bender bends The wire in (2,0,0) on the +y axis direction, and in (1,0,0) on the-yaxis direction, The result would to be:
Given a sequence of bends, you must determine what direction are pointed by the last segment of The wire (+xin the example) . You can suppose this wire can intercept itself after all it is the future!
Input
The ' a ' of each test case gives an integer L (2
L
100000) indicating the length of the wire.
The second line of each test case contains the L-1 decisions taken by Bender to each point and separated by spaces. The j-th decision in the list (for each 1
J