Noip 2011 Day 1 part (prob #1 and prob #2)

Source: Internet
Author: User
Problem 1: Carpet laying

At first glance, cry, carpet coverage... it seems to be a 2-dims line segment tree. It is so difficult at the beginning. Again, you only need to find a point, make a decisive question, and simulate it. (Note: From the enumeration with a large label to a small one, if there is a carpet that meets the requirements, the output will be returned .)

(If the entire article is not completed, the code will not be sent .)

Problem 2: Select Inn

The simulation will time out, so we use a dynamic planning method.

Use $ \ Text {sum} \ left [I \ right] $ to indicate the total number of CAF s that meet the requirements on the way from INN 1 to inn I. Naturally, the time complexity of $ \ Text {o} \ left (n \ right) $ is needless to say. You can read and collect statistics while reading.

Set the three arrays to $ f [1], F [2], and f [3] $, respectively, set a temporary variable $ T $, $ color [I] $ to the color number of inn I (fog ...). $ A [I] $ that is, the total number of solutions selected by a later person in the I-colored Inn (of course, an accumulation variable must be set for output, for example, $ S $ ), $ B [I] $ indicates the total number of valid inns scanned at this time (this color), and $ C [I] $ indicates the total number of valid CAF in this color before this time (of course, do not use the same color ). then, add the result to $ S $.

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.