UVa 11507 Bender B. Rodríguez Problem: Simulations & XOR

Source: Internet
Author: User
Tags time limit

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.