[Topcoder] srm474

Source: Internet
Author: User

Div. 2 lev. 3

Main Idea: DP

Because the number of point points in a question cannot exceed 16, we can use an integer to represent the number of point I. For example, 101 indicates the 1st point.

Because the given two-dimensional points are not ordered, all their subsets must be considered when decomposing the problem.

 

Define OPT [2 ^ N] and N as the number of two-dimensional points.

OPT [I] is the optimal result of considering the two-dimensional points represented by I.

Then the optimal sub-structure:

Opt = minj {OPT [I-j] + Res [J]}

Res [J] is the cost of using a box to frame the two-dimensional points represented by J. The initial value OPT [0] = 0, and the other value is-1.

 

Tip:

Opt definition: OPT [1 <n];

 

For (INT I = 0; I <1 <n; I ++) // a two-dimensional vertex combination of I

For (Int J = 0; j <n; j ++) // vertex J

If (I> J) & 1) // The current combination contains the J Vertex

// Calculate res

 

Optimal sub-structure (traversing the subset of all vertices represented by I ):

For (INT I = 0; I <1 <n; I ++)

For (Int J = I; j> 0; j = (J-1) & I)

 

 

 

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.